apps/web: show all documents in Files

This commit is contained in:
vchikalkin 2023-11-30 11:26:09 +03:00
parent a5eb858f4a
commit 55372c01b7
3 changed files with 10 additions and 16 deletions

View File

@ -29,10 +29,9 @@ export default async function Page(pageProps: PageProps) {
apiIUS.getData({ pageUrlParams }), apiIUS.getData({ pageUrlParams }),
apiIUS.getMetaData({ pageUrlParams }), apiIUS.getMetaData({ pageUrlParams }),
apiIUS.getConfig({ pageUrlParams }), apiIUS.getConfig({ pageUrlParams }),
apiIUS.getDocumentTypes({ pageUrlParams }),
apiIUS.getDocuments({ pageUrlParams }), apiIUS.getDocuments({ pageUrlParams }),
]).then(([data, metaData, { title }, documentTypes, documents]) => { ]).then(([data, metaData, { title }, documents]) => {
const props = { data, documentTypes, documents, metaData, pageUrlParams, title }; const props = { data, documents, metaData, pageUrlParams, title };
return <Form {...props} />; return <Form {...props} />;
}); });

View File

@ -27,14 +27,14 @@ function DownloadDocument({ document }: DownloadDocumentProps) {
} }
type FileProps = { type FileProps = {
readonly document: IUS.Document | undefined; readonly document: IUS.Document;
readonly documentType: IUS.DocumentType;
}; };
function File({ document, documentType }: FileProps) { function File({ document }: FileProps) {
const { documentTypeId, name } = documentType;
const { formFiles, setFormFiles } = useContext(FormContext); const { formFiles, setFormFiles } = useContext(FormContext);
const { documentTypeId, name } = document;
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target.files !== null) { if (event.target.files !== null) {
const file = event.target.files.item(0); const file = event.target.files.item(0);
@ -55,17 +55,13 @@ function File({ document, documentType }: FileProps) {
); );
} }
export function Files({ documentTypes, documents }: Props) { export function Files({ documents }: Props) {
return ( return (
<div className="grid gap-4"> <div className="grid gap-4">
<Heading className="text-sms">Документы</Heading> <Heading className="text-sms">Документы</Heading>
<div className="flex flex-col gap-2"> <div className="grid grid-cols-2 gap-2">
{documentTypes.map((documentType) => ( {documents.map((document) => (
<File <File key={document.documentTypeId} document={document} />
key={documentType.documentTypeId}
documentType={documentType}
document={documents.find((x) => x.documentTypeId === documentType.documentTypeId)}
/>
))} ))}
</div> </div>
</div> </div>

View File

@ -3,7 +3,6 @@ import type { PageUrlParams } from '@/utils/url';
export type Props = { export type Props = {
readonly data: IUS.ResponseGetData; readonly data: IUS.ResponseGetData;
readonly documentTypes: IUS.ResponseDocumentTypes;
readonly documents: IUS.ResponseDocuments; readonly documents: IUS.ResponseDocuments;
readonly metaData: IUS.ResponseMetaData; readonly metaData: IUS.ResponseMetaData;
readonly pageUrlParams: PageUrlParams; readonly pageUrlParams: PageUrlParams;