import { DocumentVerificationCard } from './DocumentVerificationCard';
import { useUpdateCandidateLicense } from '@/hooks/backoffice/useUpdateCandidateLicense';
import { CandidateDocumentTypes, DocumentStatuses } from '@heygermany/sdk';

type LicenseVerificationCardProps = {
  candidateId: string;
  license: any;
  documents?: any[];
  verbose?: boolean;
};

export function LicenseVerificationCard({ candidateId, license, documents = [], verbose = false }: LicenseVerificationCardProps) {
  const mutationHook = useUpdateCandidateLicense(candidateId);
  const verificationDocuments = documents
    .map((document, index) => ({
      documentId: document.documentId,
      documentStatus: document.documentStatus ?? DocumentStatuses.UNVERIFIED,
      label: document.fileName || `File ${index + 1}`
    }));

  return (
    <DocumentVerificationCard
      candidateId={candidateId}
      documents={verificationDocuments}
      category={CandidateDocumentTypes.LICENSE}
      aiExtractedData={{
        licenseNumber: license.aiLicenseNumber,
        issuingAuthority: license.aiIssuingAuthority,
        issueDate: license.aiIssueDate,
        expiryDate: license.aiExpiryDate,
        status: license.aiStatus,
        licenseType: license.aiLicenseType
      }}
      finalData={{
        licenseNumber: license.licenseNumber,
        issuingAuthority: license.issuingAuthority,
        issueDate: license.issueDate,
        expiryDate: license.expiryDate,
        status: license.status,
        licenseType: license.licenseType
      }}
      mutationHook={mutationHook}
      verbose={verbose}
      requiredFields={[]} // License: none (just need to verify its valid)
    />
  );
}
