price handling

This commit is contained in:
2026-06-22 21:09:26 +03:30
parent cc5e3ce5f2
commit e3f603b37b
8 changed files with 268 additions and 46 deletions
+19 -1
View File
@@ -26,6 +26,19 @@ const headers = {
Accept: 'application/json'
}
function formatApiErrorMessage(raw: string): string {
const unknownColumn = raw.match(/Unknown column '([^']+)'/)
if (unknownColumn) {
return `ستون «${unknownColumn[1]}» در دیتابیس وجود ندارد — سرور را به‌روز کنید یا با پشتیبانی تماس بگیرید`
}
if (raw.length > 220) {
return `${raw.slice(0, 220)}…`
}
return raw
}
const _axios = axios.create({
baseURL,
headers
@@ -82,7 +95,12 @@ _axios.interceptors.response.use(
}
} else if (error.response) {
if (!error.config?.meta?.silent) {
message.error('خطا در بارگذاری اطلاعات')
const apiMessage = error.response.data?.message
message.error(
typeof apiMessage === 'string' && apiMessage.trim()
? formatApiErrorMessage(apiMessage)
: 'خطا در بارگذاری اطلاعات',
)
}
}
// Any status codes that falls outside the range of 2xx cause this function to trigger