show error message
This commit is contained in:
@@ -25,7 +25,7 @@ export const extractErrorMessage = (
|
|||||||
): string => {
|
): string => {
|
||||||
try {
|
try {
|
||||||
const axiosError = error as { response?: { data: IGeneralError } };
|
const axiosError = error as { response?: { data: IGeneralError } };
|
||||||
return axiosError?.response?.data?.error?.details?.[0] || fallbackMessage;
|
return axiosError?.response?.data?.error?.message?.[0] || fallbackMessage;
|
||||||
} catch {
|
} catch {
|
||||||
return fallbackMessage;
|
return fallbackMessage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { useCreateCatalog } from './hooks/useHomeData'
|
|||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import { Paths } from '@/config/Paths'
|
import { Paths } from '@/config/Paths'
|
||||||
import DirectLogin from '../auth/components/DirectLogin'
|
import DirectLogin from '../auth/components/DirectLogin'
|
||||||
|
import { extractErrorMessage } from '@/helpers/utils'
|
||||||
|
|
||||||
const Home: FC = () => {
|
const Home: FC = () => {
|
||||||
|
|
||||||
@@ -26,8 +27,8 @@ const Home: FC = () => {
|
|||||||
toast('کاتالوگ با موفقیت ساخته شد', 'success')
|
toast('کاتالوگ با موفقیت ساخته شد', 'success')
|
||||||
navigate(Paths.editor + `/${data?.data?.id}`)
|
navigate(Paths.editor + `/${data?.data?.id}`)
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: (error) => {
|
||||||
toast('خطا در ساخت کاتالوگ', 'error')
|
toast(extractErrorMessage(error), 'error')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user