fix: alert i18n dialog
This commit is contained in:
parent
3aa99f2ede
commit
8fdc916955
5 changed files with 17 additions and 6 deletions
|
|
@ -21,10 +21,10 @@ const api = axios.create({ baseURL: import.meta.env.VITE_API_BASE_URL });
|
|||
|
||||
function parseError(
|
||||
status: number,
|
||||
body?: { status: number; message: string },
|
||||
body?: { status: number; message: string; code: string },
|
||||
) {
|
||||
if (status === 422) return 'ข้อมูลไม่ถูกต้อง กรุณาตรวจสอบใหม่อีกครั้ง';
|
||||
if (body && body.message) return body.message;
|
||||
if (body && body.code) return body.code;
|
||||
|
||||
return 'เกิดข้อผิดพลาดทำให้ระบบไม่สามารถทำงานได้ กรุณาลองใหม่ในภายหลัง';
|
||||
}
|
||||
|
|
@ -43,11 +43,17 @@ api.interceptors.response.use(
|
|||
(err) => {
|
||||
useLoader().hide();
|
||||
dialog({
|
||||
color: 'negative',
|
||||
color:
|
||||
err.response.status >= 400 && err.response.status < 500
|
||||
? 'warning'
|
||||
: 'negative',
|
||||
icon: 'mdi-alert',
|
||||
title: 'เกิดข้อผิดพลาด',
|
||||
actionText: 'ตกลง',
|
||||
title:
|
||||
err.response.status >= 400 && err.response.status < 500
|
||||
? 'warning'
|
||||
: 'errorOccurred',
|
||||
persistent: true,
|
||||
enablei18n: true,
|
||||
message: parseError(err.response.status, err.response.data),
|
||||
action: () => {},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue