Skip to content

Commit

Permalink
#59 <feat> : 관리자 페이지에 사용되는 zustand store 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
benidene committed Jul 18, 2024
1 parent 29004f2 commit 2922d4e
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions fe/src/store/login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {create} from "zustand";
import { devtools } from 'zustand/middleware'; // Zustand 스토어를 Redux DevTools와 연동하여 상태 변화를 시각적으로 추적할 수 있도록 설정합니다.
// console.trace()의 활용 console.trace()` 메소드는 현재 실행 중인 코드의 호출 스택을 콘솔에 출력하는 데 사용됩니다.

interface Tokens {
accessToken: string | null;
refreshToken: string | null;
}

interface AuthState {
isLoggedIn: boolean;
tokens: Tokens;
setIsLoggedIn: (status: boolean) => void;
setTokens: (tokens: Tokens) => void;
}


const useAuthStore = create(
devtools(
(set) : AuthState => ({
isLoggedIn: false,
tokens: {
accessToken: null,
refreshToken: null,
},
setIsLoggedIn: (status) => set({ isLoggedIn: status }),
setTokens: (tokens) => set({ tokens }),
})));

export default useAuthStore;


// import { create } from 'zustand';
// import { devtools } from 'zustand/middleware';

// interface Tokens {
// accessToken: string | null;
// refreshToken: string | null;
// }

// interface AuthState {
// isLoggedIn: boolean;
// tokens: Tokens;
// setIsLoggedIn: (status: boolean) => void;
// setTokens: (tokens: Tokens) => void;
// }

// const useAuthStore = create(
// devtools(
// (set) : AuthState => ({
// isLoggedIn: false,
// tokens: {
// accessToken: null,
// refreshToken: null,
// },
// setIsLoggedIn: (status) => set({ isLoggedIn: status }),
// setTokens: (tokens) => set({ tokens }),
// }))
// );

// export default useAuthStore;

0 comments on commit 2922d4e

Please sign in to comment.