diff --git a/src/front/Components/DesignSystem/UserFolder/index.tsx b/src/front/Components/DesignSystem/UserFolder/index.tsx index 8e0b391b..d0c528de 100644 --- a/src/front/Components/DesignSystem/UserFolder/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/index.tsx @@ -49,7 +49,7 @@ export default class UserFolder extends React.Component { const otherDocuments: Document[] | null = this.getValidatedAndPendindDocuments(); const redirectPath = Module.getInstance() .get() - .modules.pages.Folder.pages.AskDocument.props.path.replace("[folderUid]", this.props.folder.uid ?? ""); + .modules.pages.Folder.pages.AskDocument.props.path.replace("[folderUid]", this.props.folder.uid ?? "").replace("[customerUid]", this.props.customer.uid ?? ""); return (
{ - private documentsType: IOption[] = [ - { label: "Carte d'identité", value: "carte_identite" }, - { label: "Diagnostic État Risques et Pollution", value: "diagnostic_erep" }, - { label: "Justificatif de domicile", value: "justificatif_domicile" }, - { label: "Diagnostic gaz", value: "diagnostic_gaz" }, - { label: "Compromis de vente", value: "compromis_de_vente" }, - { label: "Diagnostic DPE", value: "diagnostic_dpe" }, - { label: "Diagnostic électrique", value: "diagnostic_electrique" }, - { label: "Diagnostic plombs", value: "diagnostic_plombs" }, - { label: "Diagnostic amiante", value: "diagnostic_amiante" }, - { label: "Diagnostic termites", value: "diagnostic_termites" }, - { label: "Diagnostic État des nuisances sonores aériennes", value: "diagnostic_ednsa" }, - ]; - public constructor(props: IPropsClass) { super(props); @@ -78,7 +66,7 @@ class AskDocumentsClass extends BasePage {
{this.state.documentTypes.map((documentType) => ( - + ))}
@@ -218,18 +206,40 @@ class AskDocumentsClass extends BasePage { }); } - private onFormSubmit( + private async onFormSubmit( e: React.FormEvent | null, values: { - [key: string]: string; + [key: string]: any; } ) { + try{ + const documentAsked: [] = values["document_types"] as []; + await documentAsked.forEach(async (document) => { + await Documents.getInstance().post({ + folder: { + uid: this.props.folderUid + }, + depositor: { + uid: this.props.customerUid + }, + document_type: { + uid: document + } + }); + }); + + this.props.router.push(Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid)); + }catch(e){ + console.error(e); + } + console.log(values["document_types"]); } } export default function AskDocuments(props: IProps){ const router = useRouter(); - let { folderUid } = router.query; + let { folderUid, customerUid } = router.query; folderUid = folderUid as string; - return ; + customerUid = customerUid as string; + return ; } diff --git a/src/front/Config/Module/development.json b/src/front/Config/Module/development.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/development.json +++ b/src/front/Config/Module/development.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/front/Config/Module/preprod.json b/src/front/Config/Module/preprod.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/preprod.json +++ b/src/front/Config/Module/preprod.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/front/Config/Module/production.json b/src/front/Config/Module/production.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/production.json +++ b/src/front/Config/Module/production.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/front/Config/Module/staging.json b/src/front/Config/Module/staging.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/staging.json +++ b/src/front/Config/Module/staging.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/pages/folders/[folderUid]/ask-documents/index.tsx b/src/pages/folders/[folderUid]/[customerUid]/ask-documents/index.tsx similarity index 100% rename from src/pages/folders/[folderUid]/ask-documents/index.tsx rename to src/pages/folders/[folderUid]/[customerUid]/ask-documents/index.tsx