(feature): login error toast

This commit is contained in:
Maksym Sadovnychyy 2025-11-20 19:39:46 +01:00
parent 67af5584fb
commit 18c5f72cf2

View File

@ -75,16 +75,17 @@ axiosInstance.interceptors.response.use(
error => { error => {
// Handle response error // Handle response error
store.dispatch(hideLoader()) store.dispatch(hideLoader())
if (error.response) { if (error.response) {
const contentType = error.response.headers['content-type'] const contentType = error.response.headers['content-type']
if (contentType && contentType.includes('application/problem+json')) { if (contentType && contentType.includes('application/problem+json')) {
const problem = error.response.data as ProblemDetails const problem = error.response.data as ProblemDetails
addToast(`${problem.title}: ${problem.detail}`, 'error') addToast(`${problem.title}: ${problem.detail}`, 'error')
if (error.response.status === 401) {
// Handle unauthorized error (e.g., redirect to login)
} }
else if (error.response.status === 401) {
const problem = error.response.data as ProblemDetails
addToast(`${problem.title}: ${problem.detail}`, 'error')
} }
} }
return Promise.reject(error) return Promise.reject(error)