import { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/shared/common/ui/alert-dialog"; import { Button } from "@/shared/common/ui/button"; import { usePositions } from "@/user-management/hooks/usePosition"; import { Loader2, AlertTriangle } from "lucide-react"; import { useTranslation } from "react-i18next"; import { useState } from "react"; import { toast } from "sonner"; interface DeleteDepartmentDialogProps { departmentName: string; departmentId: string; isOpen: boolean; onClose: () => void; } export const DeleteDepartmentDialog: React.FC = ({ departmentName, departmentId, isOpen, onClose, }) => { const { t } = useTranslation(); const [isDeleting, setIsDeleting] = useState(false); const { deletePosition: deletePositionMutation, isDeleting: isMutationDeleting } = usePositions(); const handleDelete = async () => { setIsDeleting(true); try { await deletePositionMutation({ id: departmentId, successCallback: () => { toast.success(t("department.deletedSuccessfully", "Department removed successfully")); onClose(); }, }); } catch (error: any) { // Handle error - the mutation will already show toast via hook // Just close loading state } finally { setIsDeleting(false); } }; return (
{t("department.deleteConfirm", "Delete Department?")} This will permanently delete {departmentName} and all its sub-items. This action cannot be undone.

{t("department.deleteWarning", "Make sure all employees have been reassigned before deleting.")}

{t("common.Cancel", "Cancel")}
); };