feat: standardize shared UI primitives across frontend

This commit is contained in:
chihlasm
2026-02-23 02:14:37 -05:00
parent 97cd297f46
commit 6a76e61792
20 changed files with 265 additions and 188 deletions

View File

@@ -11,8 +11,8 @@ export const apiClient = axios.create({
},
})
// Global error handler - shows toast for common API errors
// Pages can still catch errors explicitly if they need custom handling
// Global error handler for shared cases only.
// By convention, 4xx errors are handled at the page/component level.
function handleGlobalError(error: AxiosError) {
// Network error (no response from server)
if (!error.response) {
@@ -43,9 +43,8 @@ function handleGlobalError(error: AxiosError) {
return
}
// Client errors (4xx) — don't toast globally.
// Pages handle their own 4xx errors (permission checks, validation, not-found)
// and many are caught silently. Global toasts here cause noisy duplicates.
// Client errors (4xx) remain page-owned to avoid duplicate/noisy toasts.
// Global handling only covers 401/429/5xx.
if (status >= 400 && status < 500) {
return
}