diff --git a/src/common/PostOperativeHours.tsx b/src/common/PostOperativeHours.tsx index 5ed0a8d2..97ed9648 100644 --- a/src/common/PostOperativeHours.tsx +++ b/src/common/PostOperativeHours.tsx @@ -44,6 +44,7 @@ const PostOperativeHours = () => { GenericStyles.pb16, GenericStyles.br8, GenericStyles.border, + GenericStyles.whiteBackground ]} > diff --git a/src/components/utlis/apiHelper.ts b/src/components/utlis/apiHelper.ts index 042a5eee..89aeac03 100644 --- a/src/components/utlis/apiHelper.ts +++ b/src/components/utlis/apiHelper.ts @@ -19,6 +19,8 @@ import { } from '../../common/Constants'; import { ToastMessages } from '../../screens/allCases/constants'; import { alfredHandleSWWEvent } from './DeviceUtils'; +import { setWithinOperativeHours } from '@reducers/userSlice'; +import store from '@store'; export enum ApiKeys { GENERATE_OTP = 'GENERATE_OTP', @@ -210,6 +212,7 @@ export const API_STATUS_CODE = { UNPROCESSABLE_CONTENT: 422, INTERNAL_SERVER_ERROR: 500, TOO_MANY_REQUESTS: 429, + GONE: 410, }; const API_TIMEOUT_INTERVAL = 2e4; // 20s @@ -344,10 +347,12 @@ axiosInstance.interceptors.response.use( ? config.headers.showInSpecificComponents?.includes(getCurrentScreen().name) : true) ) { - toast({ - type: 'error', - text1: typeof errorString === 'string' ? errorString : API_ERROR_MESSAGE, - }); + if (API_STATUS_CODE.GONE !== response.status) { + toast({ + type: 'error', + text1: typeof errorString === 'string' ? errorString : API_ERROR_MESSAGE, + }); + } } if ([API_STATUS_CODE.UNAUTHORIZED, API_STATUS_CODE.FORBIDDEN].includes(response.status)) { @@ -355,6 +360,12 @@ axiosInstance.interceptors.response.use( dispatch(handleLogout()); } + // Blocking cosmos after operative hours + if (API_STATUS_CODE.GONE === response.status && !GLOBAL.IS_IMPERSONATED) { + if (store?.getState().user.withinOperativeHours) { + dispatch(setWithinOperativeHours(false)); + } + } return Promise.reject(error); } config.retry -= 1; diff --git a/src/reducer/userSlice.ts b/src/reducer/userSlice.ts index c98e3a91..6fa69b77 100644 --- a/src/reducer/userSlice.ts +++ b/src/reducer/userSlice.ts @@ -167,6 +167,9 @@ export const userSlice = createSlice({ state.is1To30FieldAgent = is1To30FieldAgent; state.withinOperativeHours = withinOperativeHours; }, + setWithinOperativeHours: (state, action) => { + state.withinOperativeHours = action.payload; + }, }, }); @@ -178,6 +181,7 @@ export const { setCaseSyncLock, setAgentAttendance, setUserAccessData, + setWithinOperativeHours } = userSlice.actions; export default userSlice.reducer;