Files
starr-philproperties/apps/web/src/components/generic/Dialogs/MakeAdminDialog.jsx
T
kennethobsequio b37218f90e merge new_starr_app@qas history into apps/web
git-subtree-dir: apps/web
git-subtree-mainline: eaa6d2276a
git-subtree-split: 459af9d46a
2026-08-24 12:21:16 +08:00

60 lines
1.8 KiB
React

// ─── components/MakeAdminDialog.jsx ──────────────────────────────────────────
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Spinner } from "@/components/ui/spinner";
/**
* Confirms promoting a single user to Administrator.
*
* @param {Function} onMakeAdmin (entity) => Promise
*/
export function MakeAdminDialog({
open,
onOpenChange,
entity,
onMakeAdmin,
loading,
onSuccess,
}) {
const displayName = entity?.personal_info?.name?.full_name ?? entity?.email ?? "this user";
const handleConfirm = async () => {
const res = await onMakeAdmin(entity);
if (res) {
onOpenChange(false);
onSuccess?.();
}
};
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Make Administrator</AlertDialogTitle>
<AlertDialogDescription>
Are you sure you want to grant{" "}
<span className="font-medium text-foreground">{displayName}</span>{" "}
Administrator access? They will gain full access to all administrative
features, and will be notified by email.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={loading}>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={handleConfirm} disabled={loading}>
{loading && <Spinner className="size-4 mr-2" />}
Make Admin
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}