'use client';

import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { toast } from 'sonner';
import {
  CreditAnalysisModal,
  MOCK_CREDIT_DATA,
} from '@/components/accounting/VendorManagement/CreditAnalysisModal';

export default function CreditAnalysisTestPage() {
  const [isModalOpen, setIsModalOpen] = useState(false);

  const handleApprove = () => {
    toast.success('거래가 승인되었습니다.');
  };

  return (
    <div className="container mx-auto py-8">
      <Card>
        <CardHeader>
          <CardTitle>기업 신용분석 모달 테스트</CardTitle>
          <CardDescription>
            신규 거래처 등록 시 표시되는 신용분석 모달을 테스트합니다.
          </CardDescription>
        </CardHeader>
        <CardContent className="space-y-4">
          <div className="p-4 bg-gray-50 rounded-lg">
            <h3 className="font-semibold mb-2">목업 데이터 정보</h3>
            <ul className="text-sm text-gray-600 space-y-1">
              <li>사업자번호: {MOCK_CREDIT_DATA.businessNumber}</li>
              <li>법인명: {MOCK_CREDIT_DATA.companyName}</li>
              <li>신용등급: Level {MOCK_CREDIT_DATA.creditLevel} ({MOCK_CREDIT_DATA.creditStatus})</li>
              <li>거래 승인: {MOCK_CREDIT_DATA.approval.safety}</li>
              <li>외상 가능: {MOCK_CREDIT_DATA.approval.creditAvailable ? '가능' : '불가'}</li>
            </ul>
          </div>

          <Button onClick={() => setIsModalOpen(true)}>
            신용분석 모달 열기
          </Button>
        </CardContent>
      </Card>

      <CreditAnalysisModal
        open={isModalOpen}
        onOpenChange={setIsModalOpen}
        data={MOCK_CREDIT_DATA}
        onApprove={handleApprove}
      />
    </div>
  );
}
