From 471bd6d3d74bd793f4950f9a62390ea83892e49f Mon Sep 17 00:00:00 2001 From: Nishit Suwal <81785002+NSUWAL123@users.noreply.github.com> Date: Sat, 9 Nov 2024 16:27:53 +0545 Subject: [PATCH] fix(frontend): pass additional entity file name to backend (#1860) * fix(createProjectService): pass additional_entities name to generate-project-data api * fix(createProjectService): pass null if additional_entities not upload --- src/frontend/src/api/CreateProjectService.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/api/CreateProjectService.ts b/src/frontend/src/api/CreateProjectService.ts index a6ea36d25..03d3f1eaa 100755 --- a/src/frontend/src/api/CreateProjectService.ts +++ b/src/frontend/src/api/CreateProjectService.ts @@ -190,18 +190,31 @@ const GenerateProjectFilesService = (url: string, projectData: any, formUpload: let isAPISuccess = true; try { let response; - + const additional_entities: string[] = + projectData?.additional_entities?.length > 0 ? [projectData?.additional_entities?.[0].replace(' ', '_')] : []; if (projectData.form_ways === 'custom_form') { // TODO move form upload to a separate service / endpoint? const generateApiFormData = new FormData(); generateApiFormData.append('xlsform', formUpload); + if (additional_entities?.length > 0) { + generateApiFormData.append('additional_entities', additional_entities); + } response = await axios.post(url, generateApiFormData, { headers: { 'Content-Type': 'multipart/form-data', }, }); } else { - response = await axios.post(url, {}); + const generateApiFormData = new FormData(); + generateApiFormData.append( + 'additional_entities', + additional_entities?.length > 0 ? additional_entities : null, + ); + response = await axios.post(url, generateApiFormData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); } isAPISuccess = isStatusSuccess(response.status); if (!isAPISuccess) {