Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'beta' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AruSeito committed Apr 10, 2024
2 parents a3c2efe + 19348a5 commit 895011f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/agent/src/redux/middleware/rtkQuery401ErrorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { isRejectedWithValue } from "@reduxjs/toolkit"
import type { Middleware, MiddlewareAPI } from "@reduxjs/toolkit"
import { teamAPI, userAPI } from "@illa-public/user-data"
import { removeAuthToken } from "@illa-public/utils"
import { isFetchBaseQueryError } from "../helper"

export const rtkQueryErrorLogger: Middleware =
(_api: MiddlewareAPI) => (next) => (action) => {
({ dispatch }: MiddlewareAPI) =>
(next) =>
(action) => {
if (isRejectedWithValue(action) && isFetchBaseQueryError(action.payload)) {
switch (action.payload.status) {
case 401: {
removeAuthToken()
dispatch(teamAPI.util.resetApiState())
dispatch(userAPI.util.resetApiState())
break
}
default: {
Expand Down

0 comments on commit 895011f

Please sign in to comment.