import { logout } from "@/app/store/slices/authSlice";

export const checkAuthErrorGet = (error: any, dispatch: Function,  router: any): boolean => {

  const status = error?.response?.data?.statusCode;
  const errorCode = error?.response?.data?.statusText;
  const tokenErrorCodes = [
    "Unauthorized",
  ];
  if (tokenErrorCodes.includes(errorCode) || status == 401) {
    dispatch(logout());
    router.push("/login");
    return true; 
  }
  return false; 
};