Skip to content

Commit

Permalink
fix: edit multi additional entities names replacing space with '_'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujanadh committed Nov 29, 2024
1 parent 4cf25a9 commit 598c040
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/frontend/src/api/CreateProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,34 +191,41 @@ const GenerateProjectFilesService = (url: string, projectData: any, formUpload:
try {
let response;

const additional_entities: string[] =
const additional_entities =
projectData?.additional_entities?.length > 0
? [projectData?.additional_entities?.[0]?.replaceAll(' ', '_')]
? projectData.additional_entities.map((e: string) => e.replaceAll(' ', '_'))
: [];
const generateApiFormData = new FormData();

if (additional_entities?.length > 0) {
generateApiFormData.append('additional_entities', additional_entities);
}

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 {
const payload = {
additional_entities: additional_entities.length > 0 ? additional_entities : null,
};
response = await axios.post(url, payload, {
headers: {
'Content-Type': 'application/json',
},
});
if (additional_entities?.length > 0) {
response = await axios.post(url, generateApiFormData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
} else {
const payload = {
additional_entities: null,
};
response = await axios.post(url, payload, {
headers: {
'Content-Type': 'application/json',
},
});
}
}

isAPISuccess = isStatusSuccess(response.status);
Expand Down

0 comments on commit 598c040

Please sign in to comment.