diff --git a/apps/frontend/src/app/components/ConfirmDeleteDialog.tsx b/apps/frontend/src/app/components/ConfirmDeleteDialog.tsx index 7b4adc05..b9e1d7c1 100644 --- a/apps/frontend/src/app/components/ConfirmDeleteDialog.tsx +++ b/apps/frontend/src/app/components/ConfirmDeleteDialog.tsx @@ -20,7 +20,10 @@ interface ConfirmDeleteDialogProps { * (a project's expenses, a donor's donations) — say so explicitly. */ consequences?: React.ReactNode; + prompt?: React.ReactNode; + irreversible?: boolean; confirmLabel?: string; + pendingLabel?: string; /** * Gate the confirm button behind retyping `itemName`. For deletes that * reach into financial history, where a misclick is costly to undo. @@ -40,7 +43,10 @@ export default function ConfirmDeleteDialog({ title, itemName, consequences, + prompt, + irreversible = true, confirmLabel = 'Delete', + pendingLabel = 'Deleting…', requireTypedConfirmation = false, }: ConfirmDeleteDialogProps) { const [deleting, setDeleting] = useState(false); @@ -114,22 +120,24 @@ export default function ConfirmDeleteDialog({

- {itemName ? ( + {prompt ?? (itemName ? ( <> Delete {itemName}? ) : ( 'Are you sure you want to delete this?' - )} + ))}

{consequences && (
{consequences}
)} -

- This cannot be undone. -

+ {irreversible && ( +

+ This cannot be undone. +

+ )} {requireTypedConfirmation && itemName && ( {confirmLabel} diff --git a/apps/frontend/src/app/staff/page.tsx b/apps/frontend/src/app/staff/page.tsx index a68eb60b..a14fa0bd 100644 --- a/apps/frontend/src/app/staff/page.tsx +++ b/apps/frontend/src/app/staff/page.tsx @@ -175,11 +175,21 @@ export default function StaffConsolePage() { confirmFull ? switchInto(confirmFull, 'full') : undefined } title="Act as this user with full access?" - itemName={ - confirmFull ? `${confirmFull.name} (${confirmFull.email})` : undefined + prompt={ + confirmFull && ( + <> + Switch into{' '} + + {`${confirmFull.name} (${confirmFull.email})`} + {' '} + for one hour? + + ) } consequences="Anything you create, edit, approve or delete is real and is saved as this user. Each change is also recorded against your staff account." + irreversible={false} confirmLabel="Act as" + pendingLabel="Switching…" />
); diff --git a/apps/frontend/test/components/StaffConsolePage.test.tsx b/apps/frontend/test/components/StaffConsolePage.test.tsx index 93e843d3..d00e4124 100644 --- a/apps/frontend/test/components/StaffConsolePage.test.tsx +++ b/apps/frontend/test/components/StaffConsolePage.test.tsx @@ -88,6 +88,8 @@ describe('StaffConsolePage', () => { expect(await screen.findByText('Act as this user with full access?')).toBeInTheDocument(); expect(screen.getByText('Sam Okafor (sam@branch.org)')).toBeInTheDocument(); + expect(screen.queryByText(/delete sam okafor/i)).not.toBeInTheDocument(); + expect(screen.queryByText('This cannot be undone.')).not.toBeInTheDocument(); // The dialog portals to the end of , so its confirm is the last "Act as". const confirm = screen.getAllByRole('button', { name: 'Act as' }).at(-1)!; await userEvent.click(confirm);