headplane/app/routes/users/dialogs/delete-user.tsx

41 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-02-19 13:01:20 -05:00
import Dialog from '~/components/Dialog';
2025-04-01 12:27:44 -04:00
import { Machine, User } from '~/types';
2025-02-19 13:01:20 -05:00
2025-04-01 12:27:44 -04:00
interface DeleteProps {
user: User & { machines: Machine[] };
isOpen: boolean;
setIsOpen: (isOpen: boolean) => void;
2025-02-19 13:01:20 -05:00
}
2025-04-01 12:27:44 -04:00
export default function DeleteUser({ user, isOpen, setIsOpen }: DeleteProps) {
2025-07-11 10:54:38 +02:00
const name = user.name || user.displayName;
2025-02-19 13:01:20 -05:00
return (
2025-04-01 12:27:44 -04:00
<Dialog isOpen={isOpen} onOpenChange={setIsOpen}>
<Dialog.Panel
variant={user.machines.length > 0 ? 'unactionable' : 'normal'}
>
2025-02-19 13:01:20 -05:00
<Dialog.Title>Delete {name}?</Dialog.Title>
2025-04-01 12:27:44 -04:00
{user.machines.length > 0 ? (
<Dialog.Text className="mb-6">
Users cannot be deleted if they have machines. Please delete or
re-assign their machines to other users before proceeding.
</Dialog.Text>
) : (
<Dialog.Text className="mb-6">
Deleted users cannot be recovered.
{user.provider === 'oidc' && (
<p className="mt-4 text-sm text-headplane-600 dark:text-headplane-300">
Since this user is authenticated via an external provider, they
will be recreated if they sign in again.
</p>
)}
</Dialog.Text>
)}
2025-02-19 13:01:20 -05:00
<input type="hidden" name="action_id" value="delete_user" />
<input type="hidden" name="user_id" value={user.id} />
</Dialog.Panel>
</Dialog>
);
}