Fix ticket category saving and synchronization error handling

- Updated the ticket category saving logic to handle empty description and emoji fields, ensuring they are set to null if trimmed.
- Enhanced error handling in the `maybeSyncTicketPanel` function to prevent UI errors when synchronization fails, allowing category CRUD operations to succeed.
- Updated the response handling to include support role IDs in the UI after saving, improving data consistency.
- Added validation for support role IDs in the dashboard schemas to ensure correct data types are used.
This commit is contained in:
TheOnlyMace
2026-07-25 16:24:18 +02:00
parent 5c11b68fc0
commit b5bf214d7f
5 changed files with 51 additions and 5 deletions

View File

@@ -94,18 +94,25 @@ export function TicketCategoriesManager({ guildId, initialCategories }: TicketCa
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: category.name,
description: category.description,
emoji: category.emoji,
description: category.description?.trim() ? category.description : null,
emoji: category.emoji?.trim() ? category.emoji : null,
supportRoleIds: category.supportRoleIds
})
});
const body = (await response.json().catch(() => null)) as
| (TicketCategoryDashboard & { error?: string; code?: string })
| null;
if (!response.ok || !body) {
if (!response.ok || !body || !body.id) {
toast.error(panelSyncErrorMessage(body?.code, body?.error, t));
return;
}
setCategories((prev) =>
prev.map((entry) =>
entry.clientKey === category.clientKey
? { ...body, clientKey: entry.clientKey, saving: false }
: entry
)
);
toast.success(t('common.saveSuccess'));
} catch {
toast.error(t('common.saveError'));