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; }; function File({ document }: FileProps) { const { formFiles, setFormFiles } = useContext(FormContext); const { documentId, documentTypeId, name } = document; 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({ documents }: Props) { return (
Документы
{documents.map((document) => ( ))}
); }