Skip to content

Commit

Permalink
fix(frontend): pass additional entity file name to backend (#1860)
Browse files Browse the repository at this point in the history
* fix(createProjectService): pass additional_entities name to generate-project-data api

* fix(createProjectService): pass null if additional_entities not upload
  • Loading branch information
NSUWAL123 authored Nov 9, 2024
1 parent 9ed96a6 commit 471bd6d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/frontend/src/api/CreateProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 471bd6d

Please sign in to comment.