tr]:last:border-b-0",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
+ return (
+
+ )
+}
+
+function TableHead({ className, ...props }: React.ComponentProps<"th">) {
+ return (
+ [role=checkbox]]:translate-y-[2px]",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function TableCell({ className, ...props }: React.ComponentProps<"td">) {
+ return (
+ | [role=checkbox]]:translate-y-[2px]",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function TableCaption({
+ className,
+ ...props
+}: React.ComponentProps<"caption">) {
+ return (
+
+ )
+}
+
+export {
+ Table,
+ TableHeader,
+ TableBody,
+ TableFooter,
+ TableHead,
+ TableRow,
+ TableCell,
+ TableCaption,
+}
diff --git a/src/config/gwcf.config.ts b/src/config/gwcf.config.ts
new file mode 100644
index 0000000..af76773
--- /dev/null
+++ b/src/config/gwcf.config.ts
@@ -0,0 +1,13 @@
+export const SITE_TITLE = "강원 문화예술 지원 사업 모니터링 및 종합평가";
+
+export const TOP_MENU_KEY_MAP: Record = {
+ "performance-list":"사업정보",
+ "user-list":"계정관리",
+}
+
+export const TOP_MENU_PATH_MAP: Record = {
+ "performance-list":"/performance",
+ "user-list":"/user",
+}
+
+export const MONITORING_USER_ROLE = 9003;
\ No newline at end of file
diff --git a/src/config/menu.data.ts b/src/config/menu.data.ts
new file mode 100644
index 0000000..8506314
--- /dev/null
+++ b/src/config/menu.data.ts
@@ -0,0 +1,17 @@
+import {TopMenuItem} from "@/config/menu.type";
+import {TOP_MENU_KEY_MAP, TOP_MENU_PATH_MAP} from "@/config/gwcf.config";
+
+
+
+export const TOP_MENUS: TopMenuItem[] = Object.entries(TOP_MENU_KEY_MAP).map(
+ ([key, value]) => {
+ const path = `/${TOP_MENU_PATH_MAP[key].replace(/^\/+/, "")}`;
+
+ return {
+ id: key,
+ label: value,
+ path,
+ match: (pathname: string) => pathname === path,
+ };
+ }
+);
\ No newline at end of file
diff --git a/src/config/menu.type.ts b/src/config/menu.type.ts
new file mode 100644
index 0000000..8e8fa12
--- /dev/null
+++ b/src/config/menu.type.ts
@@ -0,0 +1,6 @@
+export type TopMenuItem = {
+ id: string;
+ label: string;
+ path: string;
+ match?: (pathname: string) => boolean;
+};
\ No newline at end of file
diff --git a/src/const/common.const.ts b/src/const/common.const.ts
new file mode 100644
index 0000000..c493037
--- /dev/null
+++ b/src/const/common.const.ts
@@ -0,0 +1,3 @@
+export const UNKNOWN_HTTP_ERROR = 'UNKNOWN_HTTP_ERROR';
+export const NONE_HTTP_ERROR = 'NONE_HTTP_ERROR';
+export const VIEW_DECIMAL_POINT = 0;
\ No newline at end of file
diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts
new file mode 100644
index 0000000..429da61
--- /dev/null
+++ b/src/hooks/useAuth.ts
@@ -0,0 +1,44 @@
+"use client";
+
+import { useCallback } from "react";
+import { useAtom } from "jotai";
+import { authStateAtom, type AuthState } from "@/store/jotai/auth";
+import type { LoginUser } from "@/types/auth";
+import {MONITORING_USER_ROLE} from "@/config/gwcf.config";
+
+export const useAuth = () => {
+ const [auth, setAuth] = useAtom(authStateAtom);
+
+ // 로그인 성공 후 LoginResponse 를 바로 넣어줄 수 있게
+ const setFromLoginResponse = useCallback(
+ (res: LoginUser) => {
+ setAuth({
+ user: res
+ });
+ },
+ [setAuth],
+ );
+
+ const updateAuth = useCallback(
+ (next: AuthState | ((prev: AuthState) => AuthState)) => {
+ setAuth(next);
+ },
+ [setAuth],
+ );
+
+ const isMonitoring = auth.user?.userRole === MONITORING_USER_ROLE;
+
+ const logout = useCallback(() => {
+ setAuth({
+ user: null,
+ });
+ }, [setAuth]);
+
+ return {
+ auth,
+ isMonitoring,
+ setAuth: updateAuth,
+ setFromLoginResponse,
+ logout,
+ };
+}
diff --git a/src/hooks/useDebouncedValue.ts b/src/hooks/useDebouncedValue.ts
new file mode 100644
index 0000000..db3641c
--- /dev/null
+++ b/src/hooks/useDebouncedValue.ts
@@ -0,0 +1,12 @@
+import { useEffect, useState } from "react";
+
+export function useDebouncedValue(value: T, delayMs = 1200) {
+ const [debounced, setDebounced] = useState(value);
+
+ useEffect(() => {
+ const t = setTimeout(() => setDebounced(value), delayMs);
+ return () => clearTimeout(t);
+ }, [value, delayMs]);
+
+ return debounced;
+}
\ No newline at end of file
diff --git a/src/hooks/useDialog.ts b/src/hooks/useDialog.ts
new file mode 100644
index 0000000..9926332
--- /dev/null
+++ b/src/hooks/useDialog.ts
@@ -0,0 +1,54 @@
+import { useAtom } from 'jotai'
+import {DialogId, openDialogIdsAtom} from "@/store/jotai/dialog";
+
+export function useDialog() {
+ const [openDialogIds, setOpenDialogIds] = useAtom(openDialogIdsAtom)
+
+ /**
+ * 다이얼로그 열기
+ * @param dialogId 다이얼로그를 구분할 ID
+ * @param onlyThis true 이면 기존 다이얼로그 전부 닫고 이 것만 연다.
+ * false 이면 기존 배열에 추가한다.
+ */
+ const showDialog = (dialogId: DialogId, onlyThis: boolean = true) => {
+ setOpenDialogIds(prev => {
+ if (onlyThis) {
+ // 이 다이얼로그만 열기
+ return [dialogId]
+ }
+
+ // 이미 열려 있으면 그대로
+ if (prev.includes(dialogId)) {
+ return prev
+ }
+
+ // 여러 개 동시에 열기 허용
+ return [...prev, dialogId]
+ })
+ }
+
+ /**
+ * 다이얼로그 닫기
+ */
+ const hideDialog = (dialogId: DialogId) => {
+ setOpenDialogIds(prev => prev.filter(id => id !== dialogId))
+ }
+
+ /**
+ * 다이얼로그 열려있는지 여부
+ */
+ const isDialogOpen = (dialogId: DialogId) => openDialogIds.includes(dialogId)
+
+ /**
+ * 모든 다이얼로그 닫기 (있으면 편하니까 같이 제공)
+ */
+ const hideAll = () => setOpenDialogIds([])
+
+ return {
+ openDialogIds,
+ isDialogOpen,
+ showDialog,
+ hideDialog,
+ hideAll,
+ }
+}
\ No newline at end of file
diff --git a/src/hooks/useLayoutSelectedMenu.ts b/src/hooks/useLayoutSelectedMenu.ts
new file mode 100644
index 0000000..e76645b
--- /dev/null
+++ b/src/hooks/useLayoutSelectedMenu.ts
@@ -0,0 +1,24 @@
+"use client";
+
+import { useCallback } from "react";
+import { useAtom } from "jotai";
+import { layoutSelectedMenuAtom } from "@/store/jotai/layout";
+
+export const useLayoutSelectedMenu = () => {
+ const [selectedMenusByTopMenu, setSelectedMenusByTopMenu] = useAtom(layoutSelectedMenuAtom);
+
+ const selectMenu = useCallback(
+ (topMenuId: string, menuId: string) => {
+ setSelectedMenusByTopMenu((prev) => ({
+ ...prev,
+ [topMenuId]: menuId,
+ }));
+ },
+ [setSelectedMenusByTopMenu],
+ );
+
+ return {
+ selectedMenusByTopMenu,
+ selectMenu,
+ };
+};
diff --git a/src/hooks/useLoading.ts b/src/hooks/useLoading.ts
new file mode 100644
index 0000000..06703b7
--- /dev/null
+++ b/src/hooks/useLoading.ts
@@ -0,0 +1,56 @@
+"use client";
+
+import { useAtom } from "jotai";
+import { useCallback } from "react";
+import { loadingAtom } from "@/store/jotai/loading";
+
+export const useLoading = () => {
+ const [isLoading, setIsLoading] = useAtom(loadingAtom);
+
+ const showLoading = useCallback(() => {
+ setIsLoading(true);
+ }, [setIsLoading]);
+
+ const hideLoading = useCallback(() => {
+ setIsLoading(false);
+ }, [setIsLoading]);
+
+ /**
+ * 비동기 함수 호출 시 편하게 쓸 수 있는 래퍼
+ *
+ * 예)
+ * const { withLoading } = useLoading();
+ * await withLoading(() => apiCall());
+ */
+ const withLoadingAsync = useCallback(
+ async (fn: () => Promise): Promise => {
+ showLoading();
+ try {
+ return await fn();
+ } finally {
+ hideLoading();
+ }
+ },
+ [showLoading, hideLoading],
+ );
+
+ const withLoading = useCallback(
+ (fn: () => T): T => {
+ showLoading();
+ try {
+ return fn();
+ } finally {
+ hideLoading();
+ }
+ },
+ [showLoading, hideLoading],
+ );
+
+ return {
+ isLoading,
+ showLoading,
+ hideLoading,
+ withLoading,
+ withLoadingAsync,
+ } as const;
+}
\ No newline at end of file
diff --git a/src/hooks/useMounted.ts b/src/hooks/useMounted.ts
new file mode 100644
index 0000000..a39831c
--- /dev/null
+++ b/src/hooks/useMounted.ts
@@ -0,0 +1,7 @@
+import { useEffect, useState } from "react";
+
+export const useMounted = () => {
+ const [mounted, setMounted] = useState(false);
+ useEffect(() => setMounted(true), []);
+ return mounted;
+};
\ No newline at end of file
diff --git a/src/hooks/useResize.ts b/src/hooks/useResize.ts
new file mode 100644
index 0000000..4a86145
--- /dev/null
+++ b/src/hooks/useResize.ts
@@ -0,0 +1,22 @@
+import { useEffect, useState } from "react";
+
+export const useResizeKey = (debounceMs = 150) => {
+ const [key, setKey] = useState(0);
+
+ useEffect(() => {
+ let t: number | undefined;
+
+ const onResize = () => {
+ window.clearTimeout(t);
+ t = window.setTimeout(() => setKey((k) => k + 1), debounceMs);
+ };
+
+ window.addEventListener("resize", onResize);
+ return () => {
+ window.removeEventListener("resize", onResize);
+ window.clearTimeout(t);
+ };
+ }, [debounceMs]);
+
+ return key;
+}
\ No newline at end of file
diff --git a/src/hooks/useStorage.ts b/src/hooks/useStorage.ts
new file mode 100644
index 0000000..b7852f9
--- /dev/null
+++ b/src/hooks/useStorage.ts
@@ -0,0 +1,49 @@
+"use client";
+import {
+ setLocalStorage,
+ getLocalStorage,
+ removeLocalStorage,
+ setSessionStorage,
+ getSessionStorage,
+ removeSessionStorage,
+} from "@/store/storage/secure-storage";
+import { StorageKey, StorageType } from "@/store/storage/storage-keys";
+
+
+/**
+ * 사용법:
+ * const { set, get, remove } = useStorage(StorageKeys.SeatNumber);
+ */
+export const useStorage = (key: StorageKey) => {
+ const storageType = StorageType[key]; // "local" | "session"
+
+ const set = (value: T): void => {
+ if (storageType === "session") {
+ setSessionStorage(key, value);
+ } else {
+ setLocalStorage(key, value);
+ }
+ };
+
+ const get = (): T => {
+ if (storageType === "session") {
+ return getSessionStorage(key);
+ } else {
+ return getLocalStorage(key);
+ }
+ };
+
+ const remove = (): void => {
+ if (storageType === "session") {
+ removeSessionStorage(key);
+ } else {
+ removeLocalStorage(key);
+ }
+ };
+
+ return {
+ set,
+ get,
+ remove,
+ } as const;
+};
\ No newline at end of file
diff --git a/src/lib/env.client.ts b/src/lib/env.client.ts
new file mode 100644
index 0000000..9d534f4
--- /dev/null
+++ b/src/lib/env.client.ts
@@ -0,0 +1,15 @@
+const required = (name: K) => {
+ const v = RAW_PUBLIC_ENV[name];
+ if (!v) throw new Error(`Missing env: ${name}`);
+ return v;
+};
+
+const RAW_PUBLIC_ENV = {
+ NEXT_PUBLIC_ENV: process.env.NEXT_PUBLIC_ENV,
+ NEXT_PUBLIC_API_BASE: process.env.NEXT_PUBLIC_API_BASE,
+} as const;
+
+export const clientEnv = {
+ ENV: required("NEXT_PUBLIC_ENV"),
+ API_BASE: required("NEXT_PUBLIC_API_BASE"),
+};
\ No newline at end of file
diff --git a/src/lib/env.server.ts b/src/lib/env.server.ts
new file mode 100644
index 0000000..07768ce
--- /dev/null
+++ b/src/lib/env.server.ts
@@ -0,0 +1,10 @@
+const required = (name: string) => {
+ const v = process.env[name];
+ if (!v) throw new Error(`Missing env: ${name}`);
+ return v;
+};
+
+export const serverEnv = {
+ ENV: required("ENV"),
+ API_BACK_SERVER: required("API_BACK_SERVER"),
+};
\ No newline at end of file
diff --git a/src/lib/gwcf-util.ts b/src/lib/gwcf-util.ts
new file mode 100644
index 0000000..e69de29
diff --git a/src/lib/http-client.ts b/src/lib/http-client.ts
new file mode 100644
index 0000000..99e1973
--- /dev/null
+++ b/src/lib/http-client.ts
@@ -0,0 +1,307 @@
+import { clientEnv } from "@/lib/env.client";
+
+export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
+
+export class HttpError extends Error {
+ public readonly status: number;
+ public readonly data: unknown;
+ public readonly url: string;
+ private readonly headerMap: Record;
+
+ constructor(status: number, data: unknown, url: string, headers?: Headers) {
+ super(`HTTP ${status}`);
+ this.name = "HttpError";
+ this.status = status;
+ this.data = data;
+ this.url = url;
+ this.headerMap =
+ headers && typeof headers.entries === "function"
+ ? Object.fromEntries(headers.entries())
+ : {};
+ }
+
+ get headers(): Record {
+ return this.headerMap;
+ }
+
+ get traceId(): string | undefined {
+ return this.headerMap["x-trace-id"] ?? this.headerMap["x-request-id"];
+ }
+}
+
+export type QueryValue = string | string[] | undefined;
+export type Query = Record;
+export type PathParams = Record;
+
+export type NextFetchOptions = {
+ revalidate?: number;
+ tags?: string[];
+};
+
+export type RequestOptions = {
+ method?: HttpMethod;
+ pathParams?: PathParams;
+ query?: Query;
+ json?: unknown;
+ rawBody?: string;
+ form?: FormData;
+ headers?: Record;
+ timeoutMs?: number;
+ suppressAlert?: boolean;
+ onAuthError?: () => void;
+ autoLogoutOnAuthError?: boolean;
+ expectText?: boolean;
+ expectBinary?: boolean;
+ cache?: RequestCache; // "force-cache" | "no-store" | ...
+ next?: NextFetchOptions; // Next 서버 fetch 확장 옵션
+};
+
+export type HttpClientOptions = {
+ getToken?: () => string | null;
+ defaultTimeoutMs?: number;
+ defaultHeaders?: Record;
+ setErrorMessage?: (status: number, serverMsg?: string) => string;
+};
+
+const replacePathParams = (path: string, params?: PathParams): string => {
+ if (!params) return path;
+ let out = path;
+ for (const [k, v] of Object.entries(params)) {
+ const ph = `:${k}`;
+ if (out.includes(ph)) out = out.replace(ph, encodeURIComponent(String(v)));
+ }
+ return out;
+};
+
+const appendQuery = (u: URL, query?: Query): void => {
+ if (!query) return;
+ for (const [k, v] of Object.entries(query)) {
+ if (Array.isArray(v)) v.forEach((it) => u.searchParams.append(k, it));
+ else if (v !== undefined) u.searchParams.set(k, v);
+ }
+};
+
+const buildHeaders = (base: Record, extra?: Record): Headers => {
+ const h = new Headers(base);
+ if (extra) for (const [k, v] of Object.entries(extra)) h.set(k, v);
+ return h;
+};
+
+const isAbortError = (err: unknown): boolean => {
+ if (!err || typeof err !== "object") return false;
+ const e = err as { name?: unknown; code?: unknown; message?: unknown };
+ return (
+ e.name === "AbortError" || // browser fetch abort
+ e.code === "ABORT_ERR" || // some runtimes
+ (typeof e.message === "string" && e.message.toLowerCase().includes("aborted"))
+ );
+};
+
+const isJsonContentType = (ctype: string) => {
+ const ct = (ctype ?? "").toLowerCase()
+ return ct.includes("application/json") || ct.includes("+json")
+}
+
+export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {}) => {
+ const {
+ getToken,
+ defaultTimeoutMs = 60_000,
+ defaultHeaders = { "content-type": "application/json" },
+ setErrorMessage,
+ } = opts;
+
+ const request = async (path: string, options: RequestOptions = {}): Promise => {
+ const replaced = replacePathParams(path, options.pathParams);
+
+ let url: URL;
+ if (/^https?:\/\//i.test(replaced)) {
+ url = new URL(replaced);
+ } else if (replaced.startsWith("/")) {
+ const base = new URL(baseURL);
+ const joinedPath = `${base.pathname.replace(/\/+$/, "")}/${replaced.replace(/^\/+/, "")}`;
+ url = new URL(base.toString());
+ url.pathname = joinedPath;
+ } else {
+ url = new URL(replaced, new URL(baseURL));
+ }
+
+ appendQuery(url, options.query);
+
+ const base: Record = { ...defaultHeaders };
+ const token = getToken?.();
+ if (token) base["authorization"] = `Bearer ${token}`;
+ const headers = buildHeaders(base, options.headers);
+
+ let body: BodyInit | undefined;
+ if (options.form) {
+ headers.delete("content-type");
+ body = options.form;
+ } else if (options.rawBody !== undefined) {
+ if (!headers.has("content-type")) headers.set("content-type", "text/plain;charset=utf-8");
+ body = options.rawBody;
+ } else if (options.json !== undefined) {
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
+ body = typeof options.json === "string" ? options.json : JSON.stringify(options.json);
+ }
+
+ const controller = new AbortController();
+ const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? defaultTimeoutMs);
+
+ const isServer = typeof window === "undefined";
+ const cacheMode: RequestCache = options.cache ?? (isServer && options.next ? "force-cache" : "no-store");
+ const nextOpt = isServer ? options.next : undefined;
+
+ try {
+ const res = await fetch(url.toString(), {
+ method: options.method ?? (body ? "POST" : "GET"),
+ headers,
+ body,
+ cache: cacheMode,
+ ...(nextOpt ? ({ next: nextOpt } as any) : {}),
+ signal: controller.signal,
+ });
+
+ if (options.expectBinary) {
+ if (!res.ok) {
+ const rawText = await res.text().catch(() => "");
+ const ctype = res.headers.get("content-type") ?? ""
+ const isJson = isJsonContentType(ctype)
+
+ let parsedError: unknown;
+ if (isJson && rawText) {
+ try {
+ parsedError = JSON.parse(rawText);
+ } catch {
+ parsedError = rawText;
+ }
+ } else {
+ parsedError = rawText || null;
+ }
+
+ const autoLogout = options.autoLogoutOnAuthError ?? true;
+ const suppressAlert = options.suppressAlert ?? true;
+
+ if (res.status === 401) options.onAuthError?.();
+
+ if ((res.status === 401 || res.status === 403) && autoLogout && typeof window !== "undefined") {
+ try {
+ window.dispatchEvent(new CustomEvent("auth:expired"));
+ } catch {}
+ throw new HttpError(res.status, parsedError, url.toString(), res.headers);
+ }
+
+ if (!suppressAlert && typeof window !== "undefined") {
+ const serverMsg =
+ typeof parsedError === "object" && parsedError !== null && "message" in parsedError
+ ? String((parsedError as { message?: unknown }).message ?? "")
+ : typeof parsedError === "string"
+ ? parsedError
+ : undefined;
+
+ const msg = setErrorMessage?.(res.status, serverMsg) ?? (serverMsg ?? `HTTP ${res.status}`);
+ alert(`[${res.status}] ${msg}`);
+ }
+
+ throw new HttpError(res.status, parsedError, url.toString(), res.headers);
+ }
+
+ const buffer = await res.arrayBuffer();
+ return buffer as T;
+ }
+
+ const ctype = res.headers.get("content-type") ?? "";
+ const isJson = isJsonContentType(ctype)
+ const rawText = await res.text().catch(() => "");
+
+ const parsed: unknown = options.expectText
+ ? rawText
+ : isJson
+ ? rawText
+ ? JSON.parse(rawText)
+ : null
+ : rawText;
+
+ if (!res.ok) {
+ const autoLogout = options.autoLogoutOnAuthError ?? true;
+ const suppressAlert = options.suppressAlert ?? true;
+
+ if (res.status === 401) options.onAuthError?.();
+
+ if ((res.status === 401 || res.status === 403) && autoLogout && typeof window !== "undefined") {
+ try {
+ window.dispatchEvent(new CustomEvent("auth:expired"));
+ } catch {}
+ throw new HttpError(res.status, parsed, url.toString(), res.headers);
+ }
+
+ if (!suppressAlert && typeof window !== "undefined") {
+ const serverMsg =
+ typeof parsed === "object" && parsed !== null && "message" in parsed
+ ? String((parsed as { message?: unknown }).message ?? "")
+ : typeof parsed === "string"
+ ? parsed
+ : undefined;
+
+ const msg = setErrorMessage?.(res.status, serverMsg) ?? (serverMsg ?? `HTTP ${res.status}`);
+ alert(`[${res.status}] ${msg}`);
+ }
+
+ throw new HttpError(res.status, parsed, url.toString(), res.headers);
+ }
+
+ return parsed as T;
+ } catch (err: unknown) {
+ if (isAbortError(err)) {
+ throw new HttpError(
+ 408,
+ { message: "요청 시간이 초과되었습니다.", timeoutMs: options.timeoutMs ?? defaultTimeoutMs },
+ url.toString()
+ );
+ }
+
+ let code: string | undefined;
+ if (typeof err === "object" && err !== null) {
+ const anyErr = err as { cause?: unknown; code?: unknown };
+
+ if (anyErr.cause && typeof anyErr.cause === "object") {
+ const cause = anyErr.cause as { code?: unknown };
+ if (typeof cause.code === "string") code = cause.code;
+ }
+ if (!code && typeof anyErr.code === "string") code = anyErr.code;
+ }
+
+ if (code === "ECONNREFUSED") {
+ throw new HttpError(404, { message: "백엔드 서버를 찾을 수 없습니다." }, url.toString());
+ }
+
+ throw err;
+ } finally {
+ clearTimeout(timer);
+ }
+ };
+
+ const get = (path: string, o?: Omit) =>
+ request(path, { ...o, method: "GET" });
+
+ const post = (path: string, json?: unknown, o?: Omit) =>
+ request(path, { ...o, method: "POST", json });
+
+ const put = (path: string, json?: unknown, o?: Omit) =>
+ request(path, { ...o, method: "PUT", json });
+
+ const patch = (path: string, json?: unknown, o?: Omit) =>
+ request(path, { ...o, method: "PATCH", json });
+
+ const del = (path: string, o?: Omit) =>
+ request(path, { ...o, method: "DELETE" });
+
+ const postForm = (path: string, form: FormData, o?: Omit) =>
+ request(path, { ...o, method: "POST", form });
+
+ const putForm = (path: string, form: FormData, o?: Omit) =>
+ request(path, { ...o, method: "PUT", form });
+
+ return { request, get, post, put, patch, del, postForm, putForm };
+};
+
+export const nextApi = createHttpClient(clientEnv.API_BASE);
diff --git a/src/lib/http-util.ts b/src/lib/http-util.ts
new file mode 100644
index 0000000..6fe5a5f
--- /dev/null
+++ b/src/lib/http-util.ts
@@ -0,0 +1,52 @@
+import {NextResponse} from "next/server";
+import {HttpError} from "@/lib/http-client";
+import {clientEnv} from "@/lib/env.client";
+import {NONE_HTTP_ERROR, UNKNOWN_HTTP_ERROR} from "../const/common.const";
+
+export type ApiError = {
+ status: number
+ code: string
+ message: string
+}
+
+export const errorToResponse = (error: unknown) => {
+ if (error instanceof HttpError) {
+ const payload = error.data ?? { message: "서버에서 오류 응답을 받았습니다." }
+ return NextResponse.json(payload, { status: error.status })
+ }
+
+ return NextResponse.json(
+ { message: "서버 내부 오류가 발생했습니다." },
+ { status: 500 }
+ )
+}
+
+const isDev = clientEnv.ENV !== "prod"
+
+export const apiError = (e: unknown): ApiError => {
+ if (e instanceof HttpError) {
+ const d = e.data as any
+ const code = typeof d?.code === "string" ? d.code : UNKNOWN_HTTP_ERROR
+ const message =
+ (typeof d?.detail === "string" && d.detail) ||
+ (typeof d?.message === "string" && d.message) ||
+ (typeof d?.errMessage === "string" && d.errMessage) ||
+ (typeof d === "string" && d) ||
+ `HTTP ${e.status}`
+
+ if (isDev) {
+ console.groupCollapsed(
+ `[API ERROR] ${e.status}${code ? ` / ${code}` : ""}`
+ )
+ console.log("url:", e.url)
+ if (e.traceId) console.log("traceId:", e.traceId)
+ console.log("raw data:", d)
+ console.groupEnd()
+ }
+
+ return { status: e.status, code, message }
+ }
+
+ if (isDev) console.error("[NON-HTTP ERROR]", e)
+ return { status: 500, code: NONE_HTTP_ERROR, message: "저장에 실패했습니다." }
+}
diff --git a/src/lib/security.ts b/src/lib/security.ts
new file mode 100644
index 0000000..ad53966
--- /dev/null
+++ b/src/lib/security.ts
@@ -0,0 +1,223 @@
+import CryptoJS from "crypto-js";
+
+const KEY = CryptoJS.enc.Utf8.parse("kr!-Kfp@-fr0nT-CrypT0-Key-STR!!!");
+const IV = CryptoJS.enc.Utf8.parse("kr!-Kfp@Dash-IV!");
+const VALID_AES_KEY_BYTES = [16, 24, 32];
+const AES_IV_BYTES = 16;
+
+const validateAesConfig = () => {
+ const validKey = VALID_AES_KEY_BYTES.includes(KEY.sigBytes);
+ const validIv = IV.sigBytes === AES_IV_BYTES;
+
+ if (validKey && validIv) return;
+
+ const message = [
+ "AES 설정이 올바르지 않습니다.",
+ `KEY: ${KEY.sigBytes} bytes (허용: ${VALID_AES_KEY_BYTES.join(", ")})`,
+ `IV: ${IV.sigBytes} bytes (필수: ${AES_IV_BYTES})`,
+ ].join("\n");
+
+ if (typeof window !== "undefined" && process.env.NEXT_PUBLIC_ENV === "local") {
+ const w = window as Window & { __kfpaCryptoConfigAlerted?: boolean };
+ if (!w.__kfpaCryptoConfigAlerted) {
+ w.__kfpaCryptoConfigAlerted = true;
+ alert(message);
+ }
+ }
+};
+
+validateAesConfig();
+
+export type WordArray = CryptoJS.lib.WordArray;
+
+export class Security {
+ public static encryptBase64UrlObject(input: unknown): string {
+ const data = JSON.stringify(input);
+ return this.encryptBase64Url(data);
+ }
+
+ public static decryptBase64UrlObject(input: string): unknown {
+ const data = this.decryptBase64Url(input);
+ return JSON.parse(data);
+ }
+
+ public static encryptBase64Object(input: unknown): string {
+ const data = JSON.stringify(input);
+ return this.encryptBase64(data);
+ }
+
+ public static decryptBase64Object(input: string): unknown {
+ const data = this.decryptBase64(input);
+ return JSON.parse(data);
+ }
+
+ public static encryptBase64Url(input: string): string {
+ const data = this.decodeUtf8(input);
+ const params = this.encrypt(data);
+ return this.encodeBase64Url(params);
+ }
+
+ public static decryptBase64Url(input: string): string {
+ const data = this.decodeBase64Url(input);
+ const decryptedData = this.decrypt(data);
+ return this.encodeUtf8(decryptedData);
+ }
+
+ public static encryptBase64(input: string): string {
+ const data = this.decodeUtf8(input);
+ const params = this.encrypt(data);
+ return this.encodeBase64(params);
+ }
+ public static decryptBase64(input: string): string {
+ try {
+ const data = this.decodeBase64(input);
+ const decryptedData = this.decrypt(data);
+ return this.encodeUtf8(decryptedData);
+ } catch (error) {
+ console.error("SecurityFunction.decryptBase64 오류:", {
+ input: input?.substring(0, 50) + "...", // 처음 50자만 로그
+ error: error instanceof Error ? error.message : String(error),
+ });
+ throw error;
+ }
+ }
+
+ public static encrypt(input: WordArray): WordArray {
+ const params = CryptoJS.AES.encrypt(input, KEY, {
+ iv: IV,
+ padding: CryptoJS.pad.Pkcs7,
+ mode: CryptoJS.mode.CBC,
+ });
+ return params.ciphertext;
+ }
+
+ public static decrypt(input: WordArray): WordArray {
+ const params = CryptoJS.lib.CipherParams.create({
+ ciphertext: input,
+ });
+ return CryptoJS.AES.decrypt(params, KEY, {
+ iv: IV,
+ padding: CryptoJS.pad.Pkcs7,
+ mode: CryptoJS.mode.CBC,
+ });
+ }
+
+ public static convertUint8ArrayToWordArray(input: Uint8Array): WordArray {
+ const words: number[] = [];
+ let i = 0;
+ while (i < input.length) {
+ const word =
+ (input[i++] << 24) |
+ (input[i++] << 16) |
+ (input[i++] << 8) |
+ input[i++];
+ words.push(word);
+ }
+ return CryptoJS.lib.WordArray.create(words, words.length * 4);
+ }
+
+ public static convertWordArrayToUint8Array(input: WordArray): Uint8Array {
+ const array = new Uint8Array(input.words.length << 2);
+ for (let i = 0, j = 0; i < input.words.length; i++) {
+ const word = input.words[i];
+ array[j++] = word >> 24;
+ array[j++] = (word >> 16) & 0xff;
+ array[j++] = (word >> 8) & 0xff;
+ array[j++] = word & 0xff;
+ }
+ return array;
+ }
+
+ public static computeHmacSha256Hex(input: WordArray, key: WordArray): string {
+ return this.encodeHex(this.computeHmacSha256(input, key));
+ }
+
+ public static computeHmacSha256(input: WordArray, key: WordArray): WordArray {
+ return CryptoJS.HmacSHA256(input, key);
+ }
+
+ public static computeSha256Hex(input: WordArray): string {
+ return this.encodeHex(this.computeSha256(input));
+ }
+
+ public static computeSha256(input: WordArray): WordArray {
+ return CryptoJS.SHA256(input);
+ }
+
+ private static convertToSpecialChars(base64: string): string {
+ return Array.from(base64)
+ .map((char) => char.charCodeAt(0).toString(2).padStart(16, "0"))
+ .map((binary) => binary.replace(/0/g, "\u200b").replace(/1/g, "\u200c"))
+ .join("ㅤ");
+ }
+
+ private static convertFromSpecialChars(input: string): string {
+ return input
+ .split("ㅤ")
+ .map((bin) => bin.replace(/\u200b/g, "0").replace(/\u200c/g, "1"))
+ .map((binary) => String.fromCharCode(parseInt(binary, 2)))
+ .join("");
+ }
+
+ public static encodeBase64UrlUtf8(input: string): string {
+ return this.encodeBase64Url(this.decodeUtf8(input));
+ }
+
+ public static decodeBase64UrlUtf8(input: string): string {
+ return this.encodeUtf8(this.decodeBase64Url(input));
+ }
+
+ public static encodeBase64Url(input: WordArray): string {
+ return CryptoJS.enc.Base64url.stringify(input);
+ }
+
+ public static decodeBase64Url(input: string): WordArray {
+ if (this.hasSpecialChars(input)) {
+ const base64url = this.convertFromSpecialChars(input);
+ return CryptoJS.enc.Base64url.parse(base64url);
+ }
+
+ return CryptoJS.enc.Base64url.parse(input);
+ }
+
+ public static encodeBase64Utf8(input: string): string {
+ return this.encodeBase64(this.decodeUtf8(input));
+ }
+
+ public static decodeBase64Utf8(input: string): string {
+ return this.encodeUtf8(this.decodeBase64(input));
+ }
+
+ public static encodeBase64(input: WordArray): string {
+ return CryptoJS.enc.Base64.stringify(input);
+ }
+
+ public static decodeBase64(input: string): WordArray {
+ if (this.hasSpecialChars(input)) {
+ const base64 = this.convertFromSpecialChars(input);
+ return CryptoJS.enc.Base64.parse(base64);
+ }
+
+ return CryptoJS.enc.Base64.parse(input);
+ }
+
+ private static hasSpecialChars(input: string): boolean {
+ return input.includes("\u200b") || input.includes("\u200c");
+ }
+
+ public static encodeHex(input: WordArray): string {
+ return CryptoJS.enc.Hex.stringify(input);
+ }
+
+ public static decodeHex(input: string): WordArray {
+ return CryptoJS.enc.Hex.parse(input);
+ }
+
+ public static encodeUtf8(input: WordArray): string {
+ return CryptoJS.enc.Utf8.stringify(input);
+ }
+
+ public static decodeUtf8(input: string): WordArray {
+ return CryptoJS.enc.Utf8.parse(input);
+ }
+}
diff --git a/src/lib/server-api.ts b/src/lib/server-api.ts
new file mode 100644
index 0000000..60c9e53
--- /dev/null
+++ b/src/lib/server-api.ts
@@ -0,0 +1,20 @@
+import { cookies } from "next/headers";
+import { createHttpClient } from "@/lib/http-client";
+import { serverEnv } from "@/lib/env.server";
+
+const createServerApi = async (rootUrl: string, defaultHeaders?: Record) => {
+ const cookieStore = await cookies();
+ const accessToken = cookieStore.get("access_token")?.value ?? null;
+
+ return createHttpClient(rootUrl, {
+ getToken: () => accessToken, // 이미 위에서 읽은 값만 참조
+ defaultHeaders: {
+ "content-type": "application/json",
+ ...(defaultHeaders ?? {}),
+ },
+ });
+};
+
+export const createBackApi = () => {
+ return createServerApi(serverEnv.API_BACK_SERVER);
+}
\ No newline at end of file
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
new file mode 100644
index 0000000..e4441a2
--- /dev/null
+++ b/src/lib/utils.ts
@@ -0,0 +1,62 @@
+import { clsx, type ClassValue } from "clsx"
+import { twMerge } from "tailwind-merge"
+import {VIEW_DECIMAL_POINT} from "@/const/common.const";
+
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs))
+}
+
+export const formatKoreanBaseDate = (date = new Date()) => {
+ const year = String(date.getFullYear()).slice(-2);
+ return `${year}년 ${date.getMonth() + 1}월 ${date.getDate()}일 기준`;
+};
+
+/**
+ * 다양한 형식의 값을 숫자로 파싱합니다.
+ * - 쉼표, 퍼센트, 유니코드 마이너스 자동 처리
+ * - null/undefined/빈문자열/"−" 등은 null 반환
+ * - 유한하지 않은 숫자는 null 반환
+ */
+export function parseNumber(
+ value: unknown,
+ options?: {
+ allowComma?: boolean; // 기본값: true
+ allowPercent?: boolean; // 기본값: true
+ allowMinus?: boolean; // 기본값: true (유니코드 마이너스 포함)
+ }
+): number | null {
+ const { allowComma = true, allowPercent = true, allowMinus = true } = options ?? {};
+
+ if (value === null || value === undefined) return null;
+
+ if (typeof value === "number") {
+ return Number.isFinite(value) ? value : null;
+ }
+
+ if (typeof value === "string") {
+ let s = value.trim();
+
+ if (s === "" || s === "-" || s === "−") return null;
+
+ s = s.replaceAll("(", "");
+ s = s.replaceAll(")", "");
+
+ if (allowComma) s = s.replaceAll(",", "");
+ if (allowPercent) s = s.replaceAll("%", "");
+ if (allowMinus) s = s.replaceAll("−", "-"); // 유니코드 마이너스 -> ASCII 마이너스
+
+ const n = Number(s);
+ return Number.isFinite(n) ? n : null;
+ }
+
+ return null;
+}
+
+export const roundNumber = (num: number|null, decimalPoint?: number) => {
+ if(num == null) return null;
+
+ decimalPoint ??= VIEW_DECIMAL_POINT;
+ const factor = 10 ** decimalPoint;
+ return Math.round(num * factor) / factor;
+};
diff --git a/src/query/auth.ts b/src/query/auth.ts
new file mode 100644
index 0000000..a0375a6
--- /dev/null
+++ b/src/query/auth.ts
@@ -0,0 +1,41 @@
+"use client";
+
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { nextApi } from "@/lib/http-client";
+import { useAuth } from "@/hooks/useAuth";
+import type { LoginUser } from "@/types/auth";
+
+export const useLoginMutation = () => {
+ const { setFromLoginResponse } = useAuth();
+
+ return useMutation({
+ mutationFn: async (v: { userId: string; userPw: string;}) => {
+ return nextApi.post("/login", { userId: v.userId, userPw: v.userPw }, { autoLogoutOnAuthError: false });
+ },
+ onSuccess: (data, v) => {
+ setFromLoginResponse(data);
+ },
+ });
+}
+
+export const useLogoutMutation = () => {
+ const qc = useQueryClient();
+ const { auth, logout } = useAuth();
+
+ return useMutation({
+ mutationFn: async () => {
+ const userId = auth.user?.userId ?? "";
+ try {
+ if (userId){
+ await nextApi.post(`/logout/${userId}`, null, { autoLogoutOnAuthError: false });
+ }
+ } catch (e) {
+ console.error(e);
+ }
+ },
+ onSettled: () => {
+ logout();
+ qc.clear(); // 다음 사용자/세션에 서버상태 남지 않게
+ },
+ });
+}
\ No newline at end of file
diff --git a/src/store/cookie/client-cookie.ts b/src/store/cookie/client-cookie.ts
new file mode 100644
index 0000000..d8a5314
--- /dev/null
+++ b/src/store/cookie/client-cookie.ts
@@ -0,0 +1,105 @@
+"use client";
+
+import type { CookieKey } from "./cookie-keys";
+
+export type CookieSetOptions = {
+ days?: number; // 만료일: 기본 365일
+ path?: string; // 기본 "/"
+ secure?: boolean;
+ sameSite?: "Lax" | "Strict" | "None";
+};
+
+function isBrowser() {
+ return typeof document !== "undefined";
+}
+
+function buildCookieString(
+ key: CookieKey,
+ value: string,
+ options: CookieSetOptions = {},
+): string {
+ const {
+ days = 365,
+ path = "/",
+ secure = false,
+ sameSite = "Lax",
+ } = options;
+
+ let cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
+
+ // 만료일
+ if (Number.isFinite(days)) {
+ const expires = new Date();
+ expires.setDate(expires.getDate() + days);
+ cookie += `; Expires=${expires.toUTCString()}`;
+ }
+
+ if (path) {
+ cookie += `; Path=${path}`;
+ }
+
+ if (secure) {
+ cookie += "; Secure";
+ }
+
+ if (sameSite) {
+ cookie += `; SameSite=${sameSite}`;
+ }
+
+ return cookie;
+}
+
+export const cookieStore = {
+ /**
+ * 문자열 값 가져오기 (없으면 null)
+ */
+ get(key: CookieKey): string | null {
+ if (!isBrowser()) return null;
+
+ try {
+ const name = encodeURIComponent(key) + "=";
+ const cookies = document.cookie ? document.cookie.split("; ") : [];
+
+ for (const c of cookies) {
+ if (c.startsWith(name)) {
+ const value = c.substring(name.length);
+ return decodeURIComponent(value);
+ }
+ }
+
+ return null;
+ } catch {
+ return null;
+ }
+ },
+
+ /**
+ * 문자열 값 저장
+ */
+ set(key: CookieKey, value: string, options?: CookieSetOptions) {
+ if (!isBrowser()) return;
+
+ try {
+ const cookie = buildCookieString(key, value, options);
+ document.cookie = cookie;
+ } catch {
+ // 쿠키 설정 실패는 조용히 무시
+ }
+ },
+
+ /**
+ * 쿠키 삭제
+ */
+ remove(key: CookieKey, options?: Omit) {
+ if (!isBrowser()) return;
+
+ try {
+ document.cookie = buildCookieString(key, "", {
+ ...(options ?? {}),
+ days: -1, // 과거로 설정해서 삭제
+ });
+ } catch {
+ // 무시
+ }
+ },
+};
\ No newline at end of file
diff --git a/src/store/cookie/cookie-keys.ts b/src/store/cookie/cookie-keys.ts
new file mode 100644
index 0000000..baf188c
--- /dev/null
+++ b/src/store/cookie/cookie-keys.ts
@@ -0,0 +1,6 @@
+export const CookieKeys = {
+ AuthToken: "kri_authToken",
+ // 필요하면 여기 계속 추가 (예: Theme: "kri_theme", ...)
+} as const;
+
+export type CookieKey = (typeof CookieKeys)[keyof typeof CookieKeys];
\ No newline at end of file
diff --git a/src/store/jotai/auth.ts b/src/store/jotai/auth.ts
new file mode 100644
index 0000000..595cf95
--- /dev/null
+++ b/src/store/jotai/auth.ts
@@ -0,0 +1,20 @@
+"use client";
+
+import { createLocalStorageAtom } from "@/store/jotai/utils";
+import { StorageKeys } from "@/store/storage/storage-keys";
+import type { LoginUser } from "@/types/auth";
+
+export type AuthState = {
+ user: LoginUser | null;
+};
+
+const initialAuthState: AuthState = {
+ user: null,
+};
+/**
+ * AES 암호화된 localStorage 기반 로그인 상태 Atom
+ */
+export const authStateAtom = createLocalStorageAtom(
+ StorageKeys.AuthState,
+ initialAuthState,
+);
\ No newline at end of file
diff --git a/src/store/jotai/dialog.ts b/src/store/jotai/dialog.ts
new file mode 100644
index 0000000..240e5b0
--- /dev/null
+++ b/src/store/jotai/dialog.ts
@@ -0,0 +1,9 @@
+import { atom } from 'jotai'
+
+// 사용할 수 있는 DialogId를 타입으로 고정
+// Dialog추가 할 때만다 추가하기
+export type DialogId =
+| 'loginDialog'
+
+// 현재 열려 있는 다이얼로그 ID 리스트
+export const openDialogIdsAtom = atom([])
diff --git a/src/store/jotai/layout.ts b/src/store/jotai/layout.ts
new file mode 100644
index 0000000..377184f
--- /dev/null
+++ b/src/store/jotai/layout.ts
@@ -0,0 +1,11 @@
+"use client";
+
+import { createLocalStorageAtom } from "@/store/jotai/utils";
+import { StorageKeys } from "@/store/storage/storage-keys";
+
+export type LayoutSelectedMenuState = Record;
+
+export const layoutSelectedMenuAtom = createLocalStorageAtom(
+ StorageKeys.LayoutSelectedMenu,
+ {},
+);
diff --git a/src/store/jotai/loading.ts b/src/store/jotai/loading.ts
new file mode 100644
index 0000000..0ac0876
--- /dev/null
+++ b/src/store/jotai/loading.ts
@@ -0,0 +1,8 @@
+"use client";
+
+import { atom } from "jotai";
+
+/**
+ * 전역 로딩 상태
+ */
+export const loadingAtom = atom(false);
\ No newline at end of file
diff --git a/src/store/jotai/utils.ts b/src/store/jotai/utils.ts
new file mode 100644
index 0000000..60d5bac
--- /dev/null
+++ b/src/store/jotai/utils.ts
@@ -0,0 +1,108 @@
+"use client";
+
+import { atom, type PrimitiveAtom } from "jotai";
+import {
+ setLocalStorage,
+ getLocalStorage,
+ removeLocalStorage,
+ setSessionStorage,
+ getSessionStorage,
+ removeSessionStorage
+} from "@/store/storage/secure-storage";
+import {StorageKey} from "@/store/storage/storage-keys";
+
+const loadInitialState = (storageType: "local"|"session", key: StorageKey, initialValue: T): T => {
+ if (typeof window === "undefined") {
+ // SSR 시에는 그냥 기본값 사용
+ return initialValue;
+ }
+
+ const stored = storageType == "local" ? getLocalStorage(key) : getSessionStorage(key);
+
+ if (stored && typeof stored === "object") {
+ return stored as T;
+ }
+
+ return initialValue;
+}
+
+/**
+ * localStorage(AES 암호화) + Jotai 연동용 Atom 생성기
+ * - initialValue: SSR 시/최초 렌더 시 기본값
+ * - 마운트 후 localStorage에서 실제 값 읽어와서 덮어씀
+ */
+export const createLocalStorageAtom = (
+ key: StorageKey,
+ initialValue: T,
+) => {
+ const realInitialValue = loadInitialState("local", key, initialValue);
+ const baseAtom: PrimitiveAtom = atom(realInitialValue);
+
+ // 하이드레이션(저장소 주입)과 사용자 set 경합 방지용 플래그
+ let wasOverridden = false; // 마운트 이후 사용자가 값을 쓴 적이 있는지
+
+ const persistentAtom = atom(
+ (get) => get(baseAtom),
+ (get, set, update: T | ((prev: T) => T)) => {
+ const prev = get(baseAtom);
+ const next =
+ typeof update === "function"
+ ? (update as (prev: T) => T)(prev)
+ : update;
+
+ // 메모리 상태 갱신
+ set(baseAtom, next);
+ // 사용자 쓰기 발생 표시 (하이드레이션이 도착해도 무시하도록)
+ wasOverridden = true;
+
+ if (next === null || (next as unknown) === undefined) {
+ // 암호화 localStorage 및 캐시 제거
+ removeLocalStorage(key);
+ } else {
+ // 동기 API로 캐시를 먼저 기록하고 암호화 저장은 백그라운드 처리
+ setLocalStorage(key, next);
+ }
+ },
+ );
+
+ return persistentAtom;
+}
+
+/**
+ * sessionStorage + Jotai 연동용 Atom 생성기
+ * - 탭 단위로 유지, 탭/브라우저 닫히면 삭제
+ * - 새로고침 시 유지
+ */
+export const createSessionStorageAtom = (
+ key: StorageKey,
+ initialValue: T,
+) => {
+ const realInitialValue = loadInitialState("session", key, initialValue);
+ const baseAtom: PrimitiveAtom = atom(realInitialValue);
+
+ const persistentAtom = atom(
+ (get) => get(baseAtom),
+ (get, set, update: T | ((prev: T) => T)) => {
+ const prev = get(baseAtom);
+ const next =
+ typeof update === "function"
+ ? (update as (prev: T) => T)(prev)
+ : update;
+
+ set(baseAtom, next);
+
+ if (typeof window === "undefined") return;
+ try {
+ if (next === null || (next as unknown) === undefined) {
+ removeSessionStorage(key)
+ } else {
+ setSessionStorage(key, next);
+ }
+ } catch {
+ // sessionStorage 에러는 조용히 무시
+ }
+ },
+ );
+
+ return persistentAtom;
+}
diff --git a/src/store/storage/secure-storage.ts b/src/store/storage/secure-storage.ts
new file mode 100644
index 0000000..bf6a2e5
--- /dev/null
+++ b/src/store/storage/secure-storage.ts
@@ -0,0 +1,94 @@
+import { Security } from "@/lib/security";
+import { clientEnv } from "@/lib/env.client";
+
+type StorageValue = any;
+
+const parseStorageValue = (value: string): StorageValue => {
+ if (!value || value.trim() === "") {
+ return null;
+ }
+
+ const rawValue = clientEnv.ENV === "prod" ? Security.decryptBase64(value) : value;
+ if (!rawValue || rawValue.trim() === "") {
+ return null;
+ }
+
+ return JSON.parse(rawValue);
+};
+
+const stringifyStorageValue = (value: StorageValue): string => {
+ const rawValue = JSON.stringify(value);
+ return clientEnv.ENV === "prod" ? Security.encryptBase64(rawValue) : rawValue;
+};
+
+export const setLocalStorage = (key: string, value: StorageValue): void => {
+ try {
+ localStorage.setItem(key, stringifyStorageValue(value));
+ } catch {}
+};
+
+export const getLocalStorage = (key: string): StorageValue => {
+ try {
+ const value = localStorage.getItem(key);
+ if (value === null || value === "") {
+ return null;
+ }
+
+ try {
+ return parseStorageValue(value);
+ } catch {
+ try {
+ return JSON.parse(value);
+ } catch {
+ localStorage.removeItem(key);
+ return null;
+ }
+ }
+ } catch {
+ return null;
+ }
+};
+
+export const removeLocalStorage = (key: string): void => {
+ localStorage.removeItem(key);
+};
+
+export const clearLocalStorage = (): void => {
+ localStorage.clear();
+};
+
+export const setSessionStorage = (key: string, value: StorageValue): void => {
+ try {
+ sessionStorage.setItem(key, stringifyStorageValue(value));
+ } catch {}
+};
+
+export const getSessionStorage = (key: string): StorageValue => {
+ try {
+ const value = sessionStorage.getItem(key);
+ if (value === null || value === "") {
+ return null;
+ }
+
+ try {
+ return parseStorageValue(value);
+ } catch {
+ try {
+ return JSON.parse(value);
+ } catch {
+ sessionStorage.removeItem(key);
+ return null;
+ }
+ }
+ } catch {
+ return null;
+ }
+};
+
+export const removeSessionStorage = (key: string): void => {
+ sessionStorage.removeItem(key);
+};
+
+export const clearSessionStorage = (): void => {
+ sessionStorage.clear();
+};
diff --git a/src/store/storage/storage-keys.ts b/src/store/storage/storage-keys.ts
new file mode 100644
index 0000000..beb72bf
--- /dev/null
+++ b/src/store/storage/storage-keys.ts
@@ -0,0 +1,15 @@
+export const StorageKeys = {
+ AuthState: "kfpa:authState",
+ LayoutSelectedMenu: "kfpa:layoutSelectedMenu",
+ //CategoriFilter: "kri:categoryFilter",
+ //SidebarCollapsed: "kri:sidebarCollapsed",
+ // 필요하면 여기 계속 추가
+} as const;
+
+export const StorageType: Record = {
+ [StorageKeys.AuthState]: "local",
+ [StorageKeys.LayoutSelectedMenu]: "local",
+ //[StorageKeys.CategoriFilter]: "local",
+};
+
+export type StorageKey = (typeof StorageKeys)[keyof typeof StorageKeys];
diff --git a/src/types/auth.ts b/src/types/auth.ts
new file mode 100644
index 0000000..f3ba579
--- /dev/null
+++ b/src/types/auth.ts
@@ -0,0 +1,18 @@
+export type LoginRequest = {
+ userId: string;
+ userPw: string;
+};
+
+export type LoginResponse = {
+ accessToken: string;
+ user: LoginUser;
+};
+
+export type LoginUser = {
+ userId: string;
+ userName: string;
+ userCmpn: string;
+ userTeam: string;
+ userRole: number;
+ userDetail: Record;
+};
\ No newline at end of file
diff --git a/src/types/common.ts b/src/types/common.ts
new file mode 100644
index 0000000..f773018
--- /dev/null
+++ b/src/types/common.ts
@@ -0,0 +1,28 @@
+export type DataVerification = {
+ success: boolean;
+ fieldName : string;
+ errMessage: string;
+}
+
+export type RouteContext = { params: Promise<{ slug?: string[] }> };
+
+export type PageRequest = {
+ pageIndex: number;
+ pageSize: number;
+ sortBy: string;
+ sortDir: "asc" | "desc";
+}
+
+export type PageResponse = {
+ content: T[];
+ totalElements: number;
+ totalPages: number;
+ pageIndex: number;
+ pageSize: number;
+ numberOfElements: number;
+ first: boolean;
+ last: boolean;
+ empty: boolean;
+}
+
+export type SelectedMap = Record;
\ No newline at end of file
diff --git a/src/types/gwcf.ts b/src/types/gwcf.ts
new file mode 100644
index 0000000..e69de29
diff --git a/tsconfig.json b/tsconfig.json
index 3a13f90..cf9c65d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -19,7 +19,7 @@
}
],
"paths": {
- "@/*": ["./*"]
+ "@/*": ["./src/*"]
}
},
"include": [
|