Restyle toasts and centralize friendly error handling.
Replace the default react-toastify look with project-styled toast cards (icon chip, rounded shell, RTL-aware container, type-colored progress bar) via a new notify helper and globals.css overrides. Add a central error layer (src/lib/errors.ts): classify any caught error by HTTP status / network condition, log the full technical detail (including the raw backend message) to the console only, and surface a friendly, localized message to the user. Raw backend messages are no longer shown. All ~190 toast call sites across 22 files move to notify, routing backend errors through notify.error(err, fallback); dead apiErrorMessage/formatApiError helpers removed. Adds an `errors` section to the fa/en dictionaries. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,19 @@ const en: Dictionary = {
|
||||
currencyShort: 'T',
|
||||
},
|
||||
|
||||
errors: {
|
||||
generic: 'Something went wrong. Please try again.',
|
||||
network: 'Could not reach the server. Check your internet connection.',
|
||||
timeout: 'The server took too long to respond. Please try again.',
|
||||
unauthorized: 'Your session has expired. Please sign in again.',
|
||||
forbidden: 'You do not have permission to do this.',
|
||||
notFound: 'The requested item was not found.',
|
||||
conflict: 'This action conflicts with the current state. Refresh and try again.',
|
||||
validation: 'The information you entered is invalid. Please check your input.',
|
||||
rateLimit: 'Too many requests. Please wait a moment and try again.',
|
||||
server: 'A server error occurred. Please try again shortly.',
|
||||
},
|
||||
|
||||
language: {
|
||||
label: 'Language',
|
||||
},
|
||||
@@ -1080,7 +1093,7 @@ const en: Dictionary = {
|
||||
upgradedPaid: 'Resources upgraded! Paid {amount} Toman',
|
||||
upgradeFailed: 'Failed to upgrade resources', calcFailed: 'Failed to calculate upgrade cost',
|
||||
invoiceCreated: 'Invoice created. Choose how you want to pay.', invoiceFailed: 'Failed to create upgrade invoice',
|
||||
dbRestored: 'Database restored successfully!', dbInvalidFile: 'Please upload a .sql, .dump, or .gz file',
|
||||
dbRestored: 'Database restored successfully!', dbRestoreFailed: 'Database restore failed.', dbInvalidFile: 'Please upload a .sql, .dump, or .gz file',
|
||||
fileMax500: 'File size must be less than 500MB', dbUploadFailed: 'Failed to upload database dump',
|
||||
snapshotStarted: 'Snapshot creation started', snapshotCreateFailed: 'Failed to create snapshot',
|
||||
snapshotDeleted: 'Snapshot deleted', snapshotDeleteFailed: 'Failed to delete snapshot',
|
||||
|
||||
Reference in New Issue
Block a user