import { FormContext } from './context/form-context'; import type { Props } from './types'; import type * as IUS from '@/api/ius/types'; import { ArrowDownTrayIcon } from '@heroicons/react/24/solid'; import { Heading, InputFile } from '@repo/ui'; import Link from 'next/link'; import { useContext } from 'react'; type DownloadDocumentProps = Pick; function DownloadDocument({ document }: DownloadDocumentProps) { return document?.href ? (
Скачать
) : ( false ); } type FileProps = { readonly document: IUS.Document | undefined; readonly documentType: IUS.DocumentType; }; function File({ document, documentType }: FileProps) { const { documentTypeId, name } = documentType; const { formFiles, setFormFiles } = useContext(FormContext); const handleFileChange = (event: React.ChangeEvent) => { if (event.target.files !== null) { const file = event.target.files.item(0); if (file) setFormFiles([ ...formFiles.filter((x) => x.documentTypeId !== documentTypeId), { documentTypeId, file, name }, ]); } }; return (
); } export function Files({ documentTypes, documents }: Props) { return (
Документы
{documentTypes.map((documentType) => ( x.documentTypeId === documentType.documentTypeId)} /> ))}
); }