Add missing error message to create/update category mutation

This commit is contained in:
schroda
2025-03-16 23:24:32 +01:00
parent a2acddab5f
commit 180b975063
3 changed files with 21 additions and 11 deletions

View File

@@ -10,7 +10,7 @@ import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = { const config: CodegenConfig = {
overwrite: true, overwrite: true,
schema: 'http://localhost:4567/api/graphql', schema: 'http://localhost:45670/api/graphql',
documents: [ documents: [
'src/lib/graphql/queries/**', 'src/lib/graphql/queries/**',
'src/lib/graphql/mutations/**', 'src/lib/graphql/mutations/**',

View File

@@ -9,6 +9,7 @@
}, },
"error": { "error": {
"label": { "label": {
"create_failure": "Could not create category",
"empty": "The category is empty", "empty": "The category is empty",
"request_failure": "Could not load categories" "request_failure": "Could not load categories"
}, },
@@ -511,6 +512,14 @@
}, },
"value": "{{value}}{{unit}}" "value": "{{value}}{{unit}}"
}, },
"history": {
"error": {
"label": {
"no_history_available": "You have not read any series yet."
}
},
"title": "History"
},
"hotkeys": { "hotkeys": {
"create": { "create": {
"dialog": { "dialog": {
@@ -1522,13 +1531,5 @@
} }
}, },
"title": "Updates" "title": "Updates"
},
"history": {
"error": {
"label": {
"no_history_available": "You have not read any series yet."
}
},
"title": "History"
} }
} }

View File

@@ -33,6 +33,7 @@ import { CategorySettingsCard } from '@/modules/category/components/CategorySett
import { CategoryIdInfo } from '@/modules/category/Category.types.ts'; import { CategoryIdInfo } from '@/modules/category/Category.types.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts'; import { getErrorMessage } from '@/lib/HelperFunctions.ts';
import { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx'; import { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx';
import { makeToast } from '@/modules/core/utils/Toast.ts';
export function CategorySettings() { export function CategorySettings() {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -110,10 +111,18 @@ export function CategorySettings() {
setDialogOpen(false); setDialogOpen(false);
if (categoryToEdit === -1) { if (categoryToEdit === -1) {
requestManager.createCategory({ name: dialogName, default: dialogDefault }); requestManager
.createCategory({ name: dialogName, default: dialogDefault })
.response.catch((e) =>
makeToast(t('category.error.label.create_failure'), 'error', getErrorMessage(e)),
);
} else { } else {
const category = categories[categoryToEdit]; const category = categories[categoryToEdit];
requestManager.updateCategory(category.id, { name: dialogName, default: dialogDefault }); requestManager
.updateCategory(category.id, { name: dialogName, default: dialogDefault })
.response.catch((e) =>
makeToast(t('global.error.label.failed_to_save_changes'), 'error', getErrorMessage(e)),
);
} }
}; };