Initial commit

This commit is contained in:
payacom
2026-07-07 12:50:20 +03:30
parent 7af3af4e05
commit d234c7f859
31 changed files with 733 additions and 219 deletions

View File

@@ -11,6 +11,7 @@ import axios, {
import toast from "react-hot-toast";
import { BASE_URL as base } from "@/components/main/BaseUrl";
import Cookies from "js-cookie";
import { clearAuthSession } from "@/lib/auth/session";
const BASE_URL = base;
const axiosInstance = axios.create({
@@ -88,9 +89,14 @@ axiosInstance.interceptors.response.use(
);
const handleUnauthorized = (): void => {
if (typeof window !== "undefined") {
// toast.error("برای انجام عملیات لطفا وارد حساب کاربری خود شوید");
}
if (typeof window === "undefined") return;
const path = window.location.pathname;
if (path.startsWith("/login") || path.startsWith("/register")) return;
clearAuthSession().finally(() => {
window.location.href = "/login";
});
};
// تایپ اصلاح‌شده برای درخواست‌ها