/**
 * filekorolheader: 删除参数确认对话框 - 参数删除确认组件
 * 功能：确认删除参数、防止误操作、影响提示
 * 路径：/ai-crop-model/data-sense-center/device-parameter/components
 * 规范：遵循crop-x/docs/开发项目规范.md，使用shadcn语义化样式
 */

import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog';
import { DeviceParameterAction } from './deviceParameterReducer';
import { AlertTriangle } from 'lucide-react';

interface DeleteParameterConfirmDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  pendingDeleteParam: string | null;
  dispatch: React.Dispatch<DeviceParameterAction>;
}

export function DeleteParameterConfirmDialog({ open, onOpenChange, pendingDeleteParam, dispatch }: DeleteParameterConfirmDialogProps) {
  const confirmDelete = () => {
    if (pendingDeleteParam) {
      dispatch({ type: 'DELETE_PARAMETER', payload: pendingDeleteParam });
    }
  };

  return (
    <AlertDialog open={open} onOpenChange={onOpenChange}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle className="flex items-center gap-2 text-destructive">
            <AlertTriangle className="w-5 h-5" />
            确认删除参数
          </AlertDialogTitle>
          <AlertDialogDescription className="space-y-2">
            <p>
              确定要删除此参数吗？此操作不可撤销。
            </p>
            <p className="text-sm text-muted-foreground">
              删除后，该参数的配置和相关数据将被永久删除。
            </p>
          </AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel onClick={() => onOpenChange(false)}>取消</AlertDialogCancel>
          <AlertDialogAction
            onClick={confirmDelete}
            className="bg-destructive hover:bg-destructive/90"
          >
            确认删除
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}