'use client' import { ReactNode, useRef } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { AttnLine } from '@/components/ui/attn-line' import { ClipboardCheck, Loader2 } from 'lucide-react' interface ConfirmationDialogProps { open: boolean onOpenChange: (open: boolean) => void onConfirm: () => void isSubmitting: boolean title: string warningText?: string confirmLabel?: string extraActions?: ReactNode children: ReactNode // When true, initial focus lands on the confirm button so Enter fires the // primary action. Opt-in: never arm Enter on unrelated/destructive dialogs. autoFocusConfirm?: boolean } export function ConfirmationDialog({ open, onOpenChange, onConfirm, isSubmitting, title, // No default warning: an accounting-immutability sentence used to be baked // in here, which put it into dialogs whose authors never asked for one. // Callers that commit a voucher directly pass their own warningText. warningText, confirmLabel = 'Bekräfta & skapa', extraActions, children, autoFocusConfirm, }: ConfirmationDialogProps) { const confirmRef = useRef(null) return ( { e.preventDefault() confirmRef.current?.focus() } : undefined} >
{/* data-ph-mask on the title: confirm dialogs describe the object being acted on (convention 10), so the title is user data in session replays. The description is a static sentence and stays readable. */} {title} Granska uppgifterna innan du bekräftar
{children}
{/* Attention is one ochre sentence, not a banner (convention 6). */} {warningText && {warningText}} {extraActions}
) }