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',
|
||||
|
||||
@@ -25,6 +25,19 @@ const fa = {
|
||||
currencyShort: 'ت',
|
||||
},
|
||||
|
||||
errors: {
|
||||
generic: 'مشکلی پیش آمد. لطفاً دوباره تلاش کنید.',
|
||||
network: 'ارتباط با سرور برقرار نشد. اتصال اینترنت خود را بررسی کنید.',
|
||||
timeout: 'پاسخ سرور بیش از حد طول کشید. لطفاً دوباره تلاش کنید.',
|
||||
unauthorized: 'نشست شما منقضی شده است. لطفاً دوباره وارد شوید.',
|
||||
forbidden: 'شما اجازهٔ انجام این کار را ندارید.',
|
||||
notFound: 'مورد درخواستی پیدا نشد.',
|
||||
conflict: 'این عملیات با وضعیت فعلی تداخل دارد. صفحه را تازه کنید و دوباره تلاش کنید.',
|
||||
validation: 'اطلاعات واردشده درست نیست. لطفاً ورودیها را بررسی کنید.',
|
||||
rateLimit: 'تعداد درخواستها زیاد است. کمی صبر کنید و دوباره تلاش کنید.',
|
||||
server: 'خطایی در سرور رخ داد. لطفاً کمی بعد دوباره تلاش کنید.',
|
||||
},
|
||||
|
||||
language: {
|
||||
label: 'زبان',
|
||||
},
|
||||
@@ -1081,7 +1094,7 @@ const fa = {
|
||||
upgradedPaid: 'منابع ارتقا یافت! {amount} تومان پرداخت شد',
|
||||
upgradeFailed: 'ارتقای منابع ناموفق بود', calcFailed: 'محاسبهٔ هزینهٔ ارتقا ناموفق بود',
|
||||
invoiceCreated: 'فاکتور ساخته شد. روش پرداخت را انتخاب کن.', invoiceFailed: 'ساخت فاکتور ارتقا ناموفق بود',
|
||||
dbRestored: 'دیتابیس با موفقیت بازیابی شد!', dbInvalidFile: 'لطفاً فایل .sql، .dump یا .gz آپلود کن',
|
||||
dbRestored: 'دیتابیس با موفقیت بازیابی شد!', dbRestoreFailed: 'بازیابی دیتابیس ناموفق بود.', dbInvalidFile: 'لطفاً فایل .sql، .dump یا .gz آپلود کن',
|
||||
fileMax500: 'حجم فایل باید کمتر از ۵۰۰ مگابایت باشد', dbUploadFailed: 'آپلود dump دیتابیس ناموفق بود',
|
||||
snapshotStarted: 'ساخت اسنپشات آغاز شد', snapshotCreateFailed: 'ساخت اسنپشات ناموفق بود',
|
||||
snapshotDeleted: 'اسنپشات حذف شد', snapshotDeleteFailed: 'حذف اسنپشات ناموفق بود',
|
||||
|
||||
Reference in New Issue
Block a user