Skip to content

Commit

Permalink
fix(createProjectService): pass additional_entities name to generate-…
Browse files Browse the repository at this point in the history
…project-data api
  • Loading branch information
NSUWAL123 committed Nov 8, 2024
1 parent 10b9cb2 commit ef2589d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/frontend/src/api/CreateProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,30 @@ 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();
if (additional_entities?.length > 0) {
generateApiFormData.append('additional_entities', additional_entities);
}
response = await axios.post(url, generateApiFormData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
isAPISuccess = isStatusSuccess(response.status);
if (!isAPISuccess) {
Expand Down

0 comments on commit ef2589d

Please sign in to comment.