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

type LanguageVerificationCardProps = {
  candidateId: string;
  language: any;
  documents?: any[];
  verbose?: boolean;
};

export function LanguageVerificationCard({ candidateId, language, documents = [], verbose = false }: LanguageVerificationCardProps) {
  const mutationHook = useUpdateCandidateLanguage(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.LANGUAGE}
      aiExtractedData={{
        level: language.aiLevel,
        issuingBody: language.aiIssuingBody,
        issueDate: language.aiIssueDate,
        certifiedSkills: language.aiCertifiedSkills
      }}
      finalData={{
        level: language.level,
        issuingBody: language.issuingBody,
        issueDate: language.issueDate,
        certifiedSkills: language.certifiedSkills
      }}
      mutationHook={mutationHook}
      verbose={verbose}
      requiredFields={[
        'level'
      ]}
    />
  );
}
