mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
git-subtree-dir: apps/web git-subtree-mainline:eaa6d2276agit-subtree-split:459af9d46a
60 lines
1.8 KiB
React
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>
|
|
);
|
|
}
|