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.getMetaData({ pageUrlParams }),
apiIUS.getConfig({ pageUrlParams }),
apiIUS.getDocumentTypes({ pageUrlParams }),
apiIUS.getDocuments({ pageUrlParams }),
]).then(([data, metaData, { title }, documentTypes, documents]) => {
const props = { data, documentTypes, documents, metaData, pageUrlParams, title };
]).then(([data, metaData, { title }, documents]) => {
const props = { data, documents, metaData, pageUrlParams, title };
return <Form {...props} />;
});

View File

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

View File

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