rename: 폴더 이동 및 파일명 수정
This commit is contained in:
@@ -12,7 +12,7 @@ export function getCookie(name: string): string | undefined {
|
||||
export function setCookie(
|
||||
name: string,
|
||||
value: string,
|
||||
options: Cookies.CookieAttributes,
|
||||
options?: Cookies.CookieAttributes,
|
||||
): void {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
@@ -22,29 +22,10 @@ export function setCookie(
|
||||
|
||||
export function removeCookie(
|
||||
name: string,
|
||||
options: Cookies.CookieAttributes,
|
||||
options?: Cookies.CookieAttributes,
|
||||
): void {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
Cookies.remove(name, options);
|
||||
}
|
||||
|
||||
export function getToken(key: string): string | undefined {
|
||||
return getCookie(key);
|
||||
}
|
||||
|
||||
export function setToken(
|
||||
key: string,
|
||||
token: string,
|
||||
options: Cookies.CookieAttributes,
|
||||
): void {
|
||||
setCookie(key, token, {
|
||||
...options,
|
||||
path: "/",
|
||||
});
|
||||
}
|
||||
|
||||
export function removeToken(key: string): void {
|
||||
removeCookie(key, { path: "/" });
|
||||
}
|
||||
|
||||
+1
-19
@@ -1,24 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
getCookie,
|
||||
setCookie,
|
||||
removeCookie,
|
||||
getToken,
|
||||
setToken,
|
||||
removeToken,
|
||||
} from "../../lib/cookie";
|
||||
|
||||
import { createContext, useContext } from "react";
|
||||
import { getCookie, setCookie, removeCookie } from "../../lib/cookie";
|
||||
|
||||
export interface CookieContextType {
|
||||
getToken: (key: string) => string | undefined;
|
||||
setToken: (
|
||||
key: string,
|
||||
token: string,
|
||||
options: Cookies.CookieAttributes,
|
||||
) => void;
|
||||
removeToken: (key: string) => void;
|
||||
getCookie: (name: string) => string | undefined;
|
||||
setCookie: (
|
||||
name: string,
|
||||
@@ -32,9 +17,6 @@ export const CookieContext = createContext<CookieContextType | null>(null);
|
||||
|
||||
export function CookieProvider({ children }: { children: React.ReactNode }) {
|
||||
const cookieContextValue: CookieContextType = {
|
||||
getToken,
|
||||
setToken,
|
||||
removeToken,
|
||||
getCookie,
|
||||
setCookie,
|
||||
removeCookie,
|
||||
@@ -3,4 +3,4 @@ export {
|
||||
CookieProvider,
|
||||
useCookie,
|
||||
} from "./cookie/cookie-provider";
|
||||
export { QueryProvider } from "./query/query-client";
|
||||
export { QueryProvider } from "./query/query-provider";
|
||||
Reference in New Issue
Block a user