diff --git a/src/assets/react.svg b/src/assets/react.svg deleted file mode 100644 index 6c87de9..0000000 --- a/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/services/api-client.ts b/src/services/api-client.ts index 4f201cd..fc62906 100644 --- a/src/services/api-client.ts +++ b/src/services/api-client.ts @@ -1,6 +1,7 @@ import axios, { type AxiosInstance, type AxiosError, type InternalAxiosRequestConfig } from 'axios'; import type { RootState } from '@/store/store'; import { navigate } from '@/utils/navigation'; +import { showToast } from '@/utils/toast'; const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000/api/v1'; @@ -133,8 +134,20 @@ apiClient.interceptors.response.use( } } } - } catch (refreshError) { + } catch (refreshError: any) { processQueue(refreshError, null); + + // Check if the backend rejected the refresh due to idle inactivity + const errorCode = refreshError?.response?.data?.error?.code; + const errorMessage = refreshError?.response?.data?.error?.message; + + if (errorCode === 'SESSION_IDLE_TIMEOUT') { + // Show the backend's inactivity message as a warning toast + showToast.warning( + 'Session Expired', + errorMessage || 'You were automatically logged out due to inactivity.' + ); + } } finally { isRefreshing = false; }