Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr committed Sep 13, 2024
1 parent e0c27a0 commit 714229e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/Geopilot.Frontend/src/pages/admin/deliveryOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,15 @@ export const DeliveryOverview = () => {

function handleDelete() {
const deletePromises = selectedRows.map(row =>
fetchApi("/api/v1/delivery/" + row, { method: "DELETE" })
.then(() => null)
.catch((error: ApiError) => {
if (error.status === 404) {
showAlert(t("deliveryOverviewDeleteIdNotExistError", { id: row }), "error");
} else if (error.status === 500) {
showAlert(t("deliveryOverviewDeleteIdError", { id: row }), "error");
} else {
showAlert(t("deliveryOverviewDeleteError", { error: error }), "error");
}
}),
fetchApi("/api/v1/delivery/" + row, { method: "DELETE" }).catch((error: ApiError) => {
if (error.status === 404) {
showAlert(t("deliveryOverviewDeleteIdNotExistError", { id: row }), "error");
} else if (error.status === 500) {
showAlert(t("deliveryOverviewDeleteIdError", { id: row }), "error");
} else {
showAlert(t("deliveryOverviewDeleteError", { error: error }), "error");
}
}),
);

Promise.all(deletePromises).then(() => {
Expand Down

0 comments on commit 714229e

Please sign in to comment.