fix: completion page apis, validation, email states
This commit is contained in:
@@ -33,19 +33,29 @@ export function useApi<T, P extends any[]>(
|
||||
setData(response.data);
|
||||
return response.data;
|
||||
} catch (err: unknown) {
|
||||
const axiosError: AxiosError = err as AxiosError;
|
||||
const axiosError = err as AxiosError;
|
||||
console.log(axiosError);
|
||||
|
||||
if (axiosError.response?.status === 401) {
|
||||
navigate('/login');
|
||||
}
|
||||
|
||||
if (axiosError.response?.status === 500) {
|
||||
// Check for network error first
|
||||
if (axiosError.code === 'ERR_NETWORK') {
|
||||
toast({
|
||||
message: t('messages.serverError'),
|
||||
message: t('messages.networkError'),
|
||||
severity: 'error',
|
||||
});
|
||||
}
|
||||
// Check for HTTP status codes on the response object
|
||||
else if (axiosError.response) {
|
||||
if (axiosError.response.status === 401) {
|
||||
navigate('/login');
|
||||
}
|
||||
|
||||
if (axiosError.response.status === 500) {
|
||||
toast({
|
||||
message: t('messages.serverError'),
|
||||
severity: 'error',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setError(err);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user