-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: teamId nullable 방지하는 커스텀 훅 구현 * fix: state로 teamId 관리 * chore: sort package.json * feat: useTeamId 훅으로 teamId값 관리 * chore: useTeamId 훅 적용 * chore: 주석 삭제 * fix: undefined일 경우 0으로 저장 * fix: 워크스페이스 data undefined 방지 * feat: TeamId 전역 상태로 관리 * fix: context 파일 제거 * feat: teamId 커스텀 훅 구현 및 적용 * feat: enabled 옵션 활용해서 데이터 효율적으로 호출 * chore: 변수 설정 * fix: enabled 옵션 값 변경 * fix: solve build error * fix: 훅 내에서 useQuery 사용해서 처리 * refactor: 조건문 단순화 * fix: teamId 없을시 에러페이지로 라우팅되는 이슈 해결 * chore: 절대경로로 수정 * chore: 줄 바꿈 수정
- Loading branch information
Showing
17 changed files
with
58 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Empty file.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,19 @@ | ||
import { useClubInfoQuery } from '@/shared/hook/api/useClubInfoQuery'; | ||
import { useTeamIdAction } from '@/shared/store/team'; | ||
|
||
export const useInitializeTeamId = () => { | ||
const { setTeamId } = useTeamIdAction(); | ||
|
||
const { data, isSuccess } = useClubInfoQuery(); | ||
|
||
if (isSuccess && !localStorage.getItem('teamId')) { | ||
const teamId = data.belongTeamGetResponses[0].id; | ||
localStorage.setItem('teamId', teamId.toString()); | ||
|
||
setTeamId(teamId); | ||
|
||
return teamId; | ||
} | ||
|
||
return Number(localStorage.getItem('teamId')); | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import { create } from 'zustand'; | ||
|
||
type TeamStore = { | ||
teamId: string; | ||
teamId: number; | ||
actions: { | ||
setTeamId: (id: string) => void; | ||
setTeamId: (id: number) => void; | ||
}; | ||
}; | ||
|
||
const useTeamStore = create<TeamStore>((set) => ({ | ||
teamId: '0', | ||
teamId: Number(localStorage.getItem('teamId')), | ||
|
||
actions: { | ||
setTeamId: (teamId: string) => | ||
setTeamId: (teamId: number) => | ||
set({ | ||
teamId, | ||
}), | ||
}, | ||
})); | ||
|
||
export const useTeamId = () => useTeamStore((state) => state.teamId); | ||
|
||
export const useTeamIdAction = () => useTeamStore((state) => state.actions); |