-
Notifications
You must be signed in to change notification settings - Fork 1
[Init] Zustand 초기 세팅 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a01b254
chore: 불필요한 .gitkeep 파일 제거
u-zzn f6508fe
chore: zustand 의존성 추가
u-zzn b03cf05
feat: 토큰 저장 유틸 추가
u-zzn 960430a
feat: auth 전역 상태(store) 추가
u-zzn 45fbc27
chore: 앱 시작 시 auth 상태 동기화 추가
u-zzn 9d3ac61
chore: AuthState 타입 선언을 interface로 변경
u-zzn 44cfdf6
fix: auth store 초기값을 storage와 동기화
u-zzn 9229717
chore: token.ts 파일명을 token-storage.ts로 변경 및 관련 import 경로 수정
u-zzn ecbf342
refactor: auth store 초기 상태와 중복되는 syncFromStorage 제거
u-zzn 35d258f
refactor: App.tsx auth store 초기화와 중복된 syncFromStorage 호출 제거
u-zzn cf3da05
Merge branch 'dev' into init/#20/zustand-init
u-zzn fc06554
chore: build 에러 해결을 위한 pnpm lockfile 재생성
u-zzn 1754b31
fix: build 에러 해결을 위한 사용되지 않는 HomePage import문 제거 (#21)
u-zzn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { useAuthStore } from '@shared/model/auth'; |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| const ACCESS_TOKEN_KEY = 'accessToken'; | ||
|
|
||
| export const tokenStorage = { | ||
| get() { | ||
| return sessionStorage.getItem(ACCESS_TOKEN_KEY); | ||
| }, | ||
| set(token: string) { | ||
| sessionStorage.setItem(ACCESS_TOKEN_KEY, token); | ||
| }, | ||
| clear() { | ||
| sessionStorage.removeItem(ACCESS_TOKEN_KEY); | ||
| }, | ||
| }; |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { create } from 'zustand'; | ||
|
|
||
| import { tokenStorage } from '@/shared/lib/auth/token-storage'; | ||
|
|
||
| interface AuthState { | ||
| isLoggedIn: boolean; | ||
| actions: { | ||
| login: (accessToken: string) => void; | ||
| logout: () => void; | ||
| }; | ||
| } | ||
|
|
||
| export const useAuthStore = create<AuthState>((set) => ({ | ||
| isLoggedIn: Boolean(tokenStorage.get()), | ||
| actions: { | ||
| login: (accessToken) => { | ||
| tokenStorage.set(accessToken); | ||
| set({ isLoggedIn: true }); | ||
| }, | ||
| logout: () => { | ||
| tokenStorage.clear(); | ||
| set({ isLoggedIn: false }); | ||
| }, | ||
| }, | ||
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { useAuthStore } from './auth.store'; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 파일 이름은 자칫 '토큰 값들을 모아둔 상수 파일' 정도로 느껴질 수 있을 거 같아요! 의미가 더 드러나게
token-storage.ts로 수정해도 좋을 거 같습니다~