'use client';

/**
 * 성공 다이얼로그 (검사 등록 완료 / 입고 처리 완료)
 */

import { CheckCircle2 } from 'lucide-react';
import { Button } from '@/components/ui/button';
import {
  Dialog,
  DialogContent,
  DialogTitle,
  DialogDescription,
  VisuallyHidden,
} from '@/components/ui/dialog';

interface Props {
  open: boolean;
  type: 'inspection' | 'receiving';
  lotNo?: string;
  onClose: () => void;
}

export function SuccessDialog({ open, type, lotNo, onClose }: Props) {
  const title = type === 'inspection' ? '수입검사가 합격 처리되었습니다.' : '입고 처리가 완료되었습니다.';
  const message = type === 'inspection'
    ? `LOT번호: ${lotNo}\n입고 처리가 완료되었습니다.`
    : `LOT번호: ${lotNo}\n재고에 반영되었습니다.`;

  return (
    <Dialog open={open} onOpenChange={(newOpen) => !newOpen && onClose()}>
      <DialogContent className="max-w-sm">
        <VisuallyHidden>
          <DialogTitle>처리 완료</DialogTitle>
          <DialogDescription>처리 결과 안내</DialogDescription>
        </VisuallyHidden>
        <div className="flex flex-col items-center text-center py-6 space-y-4">
          <div className="w-16 h-16 rounded-full bg-green-100 flex items-center justify-center">
            <CheckCircle2 className="w-10 h-10 text-green-600" />
          </div>

          <div className="space-y-2">
            <h3 className="text-lg font-semibold">{title}</h3>
            <div className="text-sm text-muted-foreground whitespace-pre-line">
              {message}
            </div>
          </div>

          <Button onClick={onClose} className="w-full mt-4">
            확인
          </Button>
        </div>
      </DialogContent>
    </Dialog>
  );
}