Skip to content

Commit

Permalink
avniproject/avni-product#1531 | Invoke separate call for locations sa…
Browse files Browse the repository at this point in the history
…mple file download
  • Loading branch information
himeshr committed May 31, 2024
1 parent 2f4eec4 commit cb77662
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/upload/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ const Dashboard = ({ getStatuses, getUploadTypes, uploadTypes = new UploadTypes(
} else if (
!_.isUndefined((uploadType = uploadTypes.getCode(entityForDownload) || staticTypesWithDynamicDownload.getCode(entityForDownload)))
) {
await api.downloadDynamicSample(uploadType);
if (uploadType === "locations") {
await api.downloadLocationsSample(uploadType, mode, hierarchy);
} else {
await api.downloadDynamicSample(uploadType);
}
}
};

Expand Down
8 changes: 7 additions & 1 deletion src/upload/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ export default {
const content = await file.text();
files.download(`sample-${type}.csv`, content);
},
downloadDynamicSample: type => http.downloadFile(`/web/importSample?uploadType=${type}`, `sample-${type}.csv`)
downloadDynamicSample: type => http.downloadFile(`/web/importSample?uploadType=${type}`, `sample-${type}.csv`),
downloadLocationsSample: (type, locationUploadMode, locationHierarchy) => {
return http.downloadFile(
`/web/importSample?uploadType=${type}&locationUploadMode=${locationUploadMode}&locationHierarchy=${locationHierarchy}`,
`sample-${type}.csv`
);
}
};

0 comments on commit cb77662

Please sign in to comment.