260427_01_ENH: 리스트 다이얼로그 및 리스트 작업 시작
This commit is contained in:
@@ -64,6 +64,28 @@ export type HttpClientOptions = {
|
||||
setErrorMessage?: (status: number, serverMsg?: string) => string;
|
||||
};
|
||||
|
||||
let logoutRedirectStarted = false;
|
||||
|
||||
const canRedirectToLogout = (): boolean => {
|
||||
if (typeof window === "undefined") return false;
|
||||
if (logoutRedirectStarted) return false;
|
||||
|
||||
const { pathname } = window.location;
|
||||
if (pathname === "/logout" || pathname === "/login") return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const redirectToLogout = (): void => {
|
||||
if (!canRedirectToLogout()) return;
|
||||
|
||||
logoutRedirectStarted = true;
|
||||
|
||||
try {
|
||||
window.location.replace("/logout");
|
||||
} catch {}
|
||||
};
|
||||
|
||||
const replacePathParams = (path: string, params?: PathParams): string => {
|
||||
if (!params) return path;
|
||||
let out = path;
|
||||
@@ -186,9 +208,7 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
|
||||
if (res.status === 401) options.onAuthError?.();
|
||||
|
||||
if ((res.status === 401 || res.status === 403) && autoLogout && typeof window !== "undefined") {
|
||||
try {
|
||||
window.location.replace("/logout");
|
||||
} catch {}
|
||||
redirectToLogout();
|
||||
throw new HttpError(res.status, parsedError, url.toString(), res.headers);
|
||||
}
|
||||
|
||||
@@ -230,9 +250,7 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
|
||||
if (res.status === 401) options.onAuthError?.();
|
||||
|
||||
if ((res.status === 401 || res.status === 403) && autoLogout && typeof window !== "undefined") {
|
||||
try {
|
||||
window.location.replace("/logout");
|
||||
} catch {}
|
||||
redirectToLogout();
|
||||
throw new HttpError(res.status, parsed, url.toString(), res.headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,11 @@ import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import type {NextRequest} from "next/server";
|
||||
|
||||
export type ValueOf<T> = T[keyof T];
|
||||
|
||||
export type EnumLikeKey<T extends Record<string, unknown>> = keyof T;
|
||||
export type EnumLikeValue<T extends Record<string, unknown>> = ValueOf<T>;
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user