Skip to content

Commit 56260b0

Browse files
committed
fix: fix frontend display of error messages
1 parent 10d1564 commit 56260b0

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

site/src/pages/OrganizationSettingsPage/OrganizationSettingsPage.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { getErrorMessage } from "api/errors";
12
import {
23
deleteOrganization,
34
updateOrganization,
45
} from "api/queries/organizations";
56
import { EmptyState } from "components/EmptyState/EmptyState";
67
import { displaySuccess } from "components/GlobalSnackbar/utils";
8+
import { displayError } from "components/GlobalSnackbar/utils";
79
import { useOrganizationSettings } from "modules/management/OrganizationSettingsLayout";
810
import type { FC } from "react";
911
import { useMutation, useQueryClient } from "react-query";
@@ -42,10 +44,19 @@ const OrganizationSettingsPage: FC = () => {
4244
navigate(`/organizations/${updatedOrganization.name}/settings`);
4345
displaySuccess("Organization settings updated.");
4446
}}
45-
onDeleteOrganization={() => {
46-
deleteOrganizationMutation.mutate(organization.id);
47-
displaySuccess("Organization deleted.");
48-
navigate("/organizations");
47+
onDeleteOrganization={async () => {
48+
try {
49+
await deleteOrganizationMutation.mutateAsync(organization.id);
50+
displaySuccess(`Organization ${organization.name} deleted`);
51+
navigate("/organizations");
52+
} catch (error) {
53+
displayError(
54+
getErrorMessage(
55+
error,
56+
`Failed to delete organization: ${organization.name}`,
57+
),
58+
);
59+
}
4960
}}
5061
/>
5162
);

site/src/pages/OrganizationSettingsPage/OrganizationSettingsPageView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ export const OrganizationSettingsPageView: FC<
146146

147147
<DeleteDialog
148148
isOpen={isDeleting}
149-
onConfirm={onDeleteOrganization}
149+
onConfirm={async () => {
150+
await onDeleteOrganization();
151+
setIsDeleting(false);
152+
}}
150153
onCancel={() => setIsDeleting(false)}
151154
entity="organization"
152155
name={organization.name}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy