import { useDispatch, useSelector } from "react-redux"; import type { RootState } from "../store"; import { interceptorActions } from "./interceptor.slice"; import type { IInterceptorStore } from "./interceptor-store.types"; export const NETWORK_ERROR_THRESHOLD = 3; export const useInterceptorStore = () => { const interceptorStore = useSelector( (state) => state.interceptor, ); const dispatch = useDispatch(); function incrementNetworkErrorCount() { dispatch(interceptorActions.incrementNetworkErrorCount()); } function resetNetworkErrorCount() { dispatch(interceptorActions.resetNetworkErrorCount()); } return { networkError: { count: interceptorStore.networkErrorCount, increment: incrementNetworkErrorCount, reset: resetNetworkErrorCount, }, }; };