Skip to content

Commit 2746f4b

Browse files
committed
fix(admin): show proper backend error when deleting
1 parent 627f7f7 commit 2746f4b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dashboard/src/pages/_dashboard.admins.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { AdminDetails } from '@/service/api'
1212
import AdminsStatistics from '@/components/admin-statistics.tsx'
1313
import { zodResolver } from '@hookform/resolvers/zod'
1414
import { queryClient } from '@/utils/query-client.ts'
15+
import useDynamicErrorHandler from '@/hooks/use-dynamic-errors'
1516

1617
const initialDefaultValues: Partial<AdminFormValues> = {
1718
username: '',
@@ -50,6 +51,7 @@ export default function AdminsPage() {
5051
const modifyDisableAllAdminUsers = useDisableAllActiveUsers()
5152
const modifyActivateAllAdminUsers = useActivateAllDisabledUsers()
5253
const resetUsageMutation = useResetAdminUsage()
54+
const handleError = useDynamicErrorHandler()
5355
const handleDelete = async (admin: AdminDetails) => {
5456
try {
5557
await removeAdminMutation.mutateAsync({
@@ -64,11 +66,11 @@ export default function AdminsPage() {
6466
// Invalidate nodes queries
6567
queryClient.invalidateQueries({ queryKey: ['/api/admins'] })
6668
} catch (error) {
67-
toast.error(t('error', { defaultValue: 'Error' }), {
68-
description: t('admins.deleteFailed', {
69-
name: admin.username,
70-
defaultValue: 'Failed to delete node «{{name}}»',
71-
}),
69+
handleError({
70+
error,
71+
fields: [],
72+
form,
73+
contextKey: 'admins',
7274
})
7375
}
7476
}

0 commit comments

Comments
 (0)