2人確認CoSignExperimental
Two-person verification (2人確認 / ダブルチェック / co-sign): a second actor enters their id (guarded to differ from the primary), ticks the required attestations, and signs — producing a timestamped signed value the consumer reads to gate an action. For medication double-checks, controlled substances, transfusion, surgical time-outs, and finance maker-checker approvals.
プレビュー
Props
表は横にスクロールできます
| プロパティ | 型 | 初期値 | 説明 |
|---|---|---|---|
| primaryId | string | - | The primary actor's id — the second signer must differ from this (same-person guard). |
| attestations | { id: string; label: ReactNode }[] | - | Attestation checkboxes — all must be ticked before signing. |
| value | CoSignValue | - | Controlled signed value (undefined = pending). When set, renders the signed read-only state. |
| onSign | (value: CoSignValue) => void | - | Fired when the second person signs. CoSignValue = { signerId, reason?, attestedAt, attestations }. |
| requireReason | boolean | - | Require a reason before signing. Default false. |
| minSignerLength | number | 1 | Minimum signer-id length. |
| signerLabel / reasonLabel / samePersonError | ReactNode | - | Field labels and the same-person error message. |
| CoSignBadge | { value?: CoSignValue } | - | Companion badge — renders "2人確認 済" (success) when signed, "2人確認 要" (warning) when pending. |
| className | string | - | Additional CSS class names. |
Usage
import { CoSign, CoSignBadge, type CoSignValue } from "@gunjo/ui"
const [value, setValue] = useState<CoSignValue>()
<CoSign
primaryId="ns-tanaka" // the 2nd signer must differ from this
attestations={[
{ id: "drug", label: "薬剤名・規格・用量を確認した" },
{ id: "patient", label: "患者・指示を確認した" },
]}
value={value} // set ⇒ signed (read-only); undefined ⇒ pending
onSign={setValue} // CoSignValue { signerId, reason?, attestedAt, attestations }
/>
<Button disabled={!value}>麻薬を投与</Button> // gate the action on the co-sign