NTP-8286 | Block cosmos
This commit is contained in:
@@ -44,6 +44,7 @@ const PostOperativeHours = () => {
|
||||
GenericStyles.pb16,
|
||||
GenericStyles.br8,
|
||||
GenericStyles.border,
|
||||
GenericStyles.whiteBackground
|
||||
]}
|
||||
>
|
||||
<View style={styles.iconContainer}>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user