/**
 * filekorolheader: 部门删除对话框组件 - 部门删除确认界面
 * 功能：删除确认、影响说明、操作处理
 * 路径：/central-config/user/department/components/DepartmentDeleteDialog
 * 规范：遵循crop-x/docs/开发项目规范.md，使用shadcn/ui组件，TypeScript类型安全
 */

import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { AlertTriangle } from 'lucide-react';
import { Department } from '../types';

interface DepartmentDeleteDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  deletingDepartment: Department | null;
  onConfirm: () => void;
}

export function DepartmentDeleteDialog({
  open,
  onOpenChange,
  deletingDepartment,
  onConfirm
}: DepartmentDeleteDialogProps) {
  const handleConfirm = async () => {
    try {
      await onConfirm();
    } catch (error) {
      console.error('Failed to delete department:', error);
    }
  };

  return (
    <Dialog open={open} onOpenChange={onOpenChange}>
      <DialogContent className="max-w-md">
        <DialogHeader>
          <DialogTitle>确认删除部门</DialogTitle>
        </DialogHeader>

        <DialogDescription className="text-left">
          {deletingDepartment ? (
            <div className="space-y-3">
              <p>
                确定要删除部门 <strong>{deletingDepartment.name}</strong> 吗？
              </p>
              <p className="text-sm text-muted-foreground">
                此操作不可撤销，请谨慎操作。
              </p>
            </div>
          ) : (
            <p>确定要删除选中的部门吗？</p>
          )}
        </DialogDescription>

        <DialogFooter>
          <Button variant="outline" onClick={() => onOpenChange(false)}>
            取消
          </Button>
          <Button
            variant="destructive"
            onClick={handleConfirm}
          >
            删除
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}