Skip to content

Commit

Permalink
[#190] Change apiUrl in importRecords from /rest/records/import/{file…
Browse files Browse the repository at this point in the history
…Type} to one single endpoint /rest/records/import
  • Loading branch information
palagdan committed Jul 23, 2024
1 parent c298508 commit 964f7a1
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/actions/RecordsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,10 @@ export function importRecords(file) {
return (dispatch) => {
dispatch(asyncRequest(ActionConstants.IMPORT_RECORDS_PENDING));

const fileExtension = file.name.split(".").pop().toLowerCase();

const formData = new FormData();
formData.append("file", file);

let apiUrl = `${API_URL}/rest/records/import`;
if (fileExtension === "json") {
apiUrl = `${API_URL}/rest/records/import/json`;
} else if (["xls", "xlsx"].includes(fileExtension)) {
apiUrl = `${API_URL}/rest/records/import/excel`;
} else if (["tsv"].includes(fileExtension)) {
apiUrl = `${API_URL}/rest/records/import/tsv`;
} else {
const error = new Error("Unsupported file format");
dispatch(asyncError(ActionConstants.IMPORT_RECORDS_ERROR, error));
return Promise.reject(error);
}

return axiosBackend
.post(apiUrl, formData, {
Expand Down

0 comments on commit 964f7a1

Please sign in to comment.