DualApprovalButton

Four-eyes / segregation-of-duties approval button. Each click adds the current user's id to an approver array on the record; once the count reaches required, the status flips to approved. Self-approval is blocked.

Installation

pnpm dlx shadcn@latest add @shadmin/dual-approval-button

Usage

import { DualApprovalButton, Show, RecordField } from "@/components/admin";
 
const ExpenseShow = () => (
  <Show>
    <RecordField source="title" />
    <DualApprovalButton required={2} />
  </Show>
);

Props

PropRequiredTypeDefaultDescription
requiredOptionalnumber2Approvers needed
approverSourceOptionalstring"approvers"Field for the approver id array
statusSourceOptionalstring"status"Field flipped to "approved" on threshold
resourceOptionalstringContextOverride resource

Record shape

The record must carry an array field (default name approvers) holding the ids of users who have already approved. When approvers.length >= required, the button renders a "Fully approved" badge instead of the action button.

Self-approval blocking

useGetIdentity() provides the current user's id. If that id is already in approvers, the button is disabled with a "You already approved" tooltip.