Skip to content

Commit 5942862

Browse files
authored
[Fix] QA 배포본 로그인 에러 해결 (#432)
* fix: teamId 있을 시 dashboard로 * feat: teamId prop 추가 + spinner 위치 수정 * fix: teamId 관리 로직 수정 * fix: global state가 아닌 localstorage get * fix: query -> suspensequery
1 parent 1b7e69c commit 5942862

File tree

10 files changed

+28
-25
lines changed

10 files changed

+28
-25
lines changed

apps/client/src/page/dashboard/component/File/FileSection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { extractFileExtension } from '@/shared/util/file';
1515

1616
const FileSection = () => {
1717
const teamId = useInitializeTeamId();
18+
1819
const { data: fileData } = $api.useQuery('get', '/api/v1/teams/{teamId}/drive', {
1920
params: {
2021
path: {

apps/client/src/page/dashboard/component/Handover/HandoverSection.style.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { dashboradScrollStyle } from '@/page/dashboard/DashboardPage.style';
55

66
export const listItemStyle = css(
77
{
8-
flexDirection: 'column',
9-
gap: '0.8rem',
108
height: '100%',
119

1210
overflowY: 'scroll',

apps/client/src/page/dashboard/component/Handover/HandoverSection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import { useCurrentDate } from '@/shared/hook/common/useCurrentDate';
1010

1111
const HandoverSection = () => {
1212
const createdAt = useCurrentDate();
13-
const { data, isFetching } = useNoteData(createdAt);
13+
const { data, isPending } = useNoteData(createdAt);
1414

1515
return (
16-
<Flex css={listItemStyle}>
16+
<Flex styles={{ direction: 'column', gap: '0.8rem', align: 'center' }} css={listItemStyle}>
1717
{!data?.data?.noteGetResponseList[0] && <ItemAdder path={PATH.HANDOVER} />}
1818

19-
{isFetching ? (
19+
{isPending ? (
2020
<Spinner size={30} />
2121
) : (
2222
data?.data?.noteGetResponseList.map((note) => {

apps/client/src/page/dashboard/component/Timeline/Timeline/Timeline.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ import { timelineContentStyle } from '@/page/dashboard/component/Timeline/Timeli
1010

1111
import { $api } from '@/shared/api/client';
1212
import { PATH } from '@/shared/constant/path';
13-
import { useInitializeTeamId } from '@/shared/hook/common/useInitializeTeamId';
1413

15-
const Timeline = () => {
14+
const Timeline = ({ teamId }: { teamId: number }) => {
1615
const navigate = useNavigate();
1716

18-
const teamId = useInitializeTeamId();
19-
2017
const { currentYear, currentMonth, endDay } = useDateContext();
2118

2219
const { data } = $api.useQuery(

apps/client/src/page/dashboard/component/Timeline/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const TimelineSection = () => {
1313
<DateProvider teamId={teamId}>
1414
<TimeLineHeader />
1515
<Suspense>
16-
<Timeline />
16+
<Timeline teamId={teamId} />
1717
</Suspense>
1818
</DateProvider>
1919
);

apps/client/src/page/drive/hook/api/queries.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { $api } from '@/shared/api/client';
2-
import { useTeamId } from '@/shared/store/team';
2+
import { useInitializeTeamId } from '@/shared/hook/common/useInitializeTeamId';
33

44
export const useDriveData = () => {
5-
const teamId = useTeamId();
5+
const teamId = useInitializeTeamId();
66

77
return $api.useSuspenseQuery('get', '/api/v1/teams/{teamId}/drive', {
88
params: {

apps/client/src/page/login/index/hook/useLoginMutation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export const useLoginMutation = () => {
2626

2727
axiosInstance.defaults.headers.Authorization = `Bearer ${accessToken}`;
2828

29-
navigate(PATH.DASHBOARD);
29+
const isExistingUser = !!localStorage.getItem('teamId');
30+
31+
isExistingUser
32+
? navigate(`${PATH.DASHBOARD}?teamId=${localStorage.getItem('teamId')}`)
33+
: navigate(PATH.ONBOARDING);
3034
},
3135

3236
onError: (error: AxiosError) => {

apps/client/src/shared/component/SideNavBar/SideNavBar.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,28 @@ import Item from '@/shared/component/SideNavBar/Item/Item';
99
import { containerStyle, settingStyle, tikiLogoStyle } from '@/shared/component/SideNavBar/SideNavBar.style';
1010
import { PATH } from '@/shared/constant/path';
1111
import { useOpenModal } from '@/shared/store/modal';
12+
import { useTeamId, useTeamIdAction } from '@/shared/store/team';
1213
import { Team } from '@/shared/type/team';
1314

1415
const SideNavBar = () => {
15-
const [selectedId, setSelectedId] = useState('showcase');
16+
const [isInShowcase, setIsInShowcase] = useState(false);
1617

18+
const teamId = useTeamId();
19+
const { setTeamId } = useTeamIdAction();
1720
const navigate = useNavigate();
18-
1921
const openModal = useOpenModal();
2022

21-
const { data } = $api.useQuery('get', '/api/v1/members/teams', {});
23+
const { data } = $api.useQuery('get', '/api/v1/members/teams');
2224

2325
const handleItemClick = (id: string, path: string) => {
24-
setSelectedId(id);
25-
2626
if (id === 'showcase') {
27+
setTeamId(null);
28+
setIsInShowcase(true);
2729
navigate(path);
2830
} else {
29-
navigate(path);
31+
setTeamId(+id);
3032
localStorage.setItem('teamId', id);
33+
navigate(path);
3134
}
3235
close();
3336
};
@@ -42,15 +45,15 @@ const SideNavBar = () => {
4245
<Flex tag="ul" styles={{ direction: 'column', align: 'center' }}>
4346
<Item
4447
variant={{ type: 'dashboard', hoverMessage: 'showcase' }}
45-
isClicked={selectedId === 'showcase'}
48+
isClicked={isInShowcase}
4649
onLogoClick={() => handleItemClick('showcase', PATH.SHOWCASE)}
4750
/>
4851
<Divider type="horizontal" size={56.78} color={theme.colors.gray_300} />
4952
{data?.data?.belongTeamGetResponses.map((data: Team) => {
5053
return (
5154
<Item
5255
key={data.id}
53-
isClicked={selectedId === String(data.id)}
56+
isClicked={teamId === data.id}
5457
variant={{ type: 'team', logoUrl: data.iconImageUrl, hoverMessage: data.name }}
5558
onLogoClick={() => handleItemClick(String(data.id), `${PATH.DASHBOARD}?teamId=${data.id}`)}
5659
/>

apps/client/src/shared/hook/common/useInitializeTeamId.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const useInitializeTeamId = () => {
1212
const { setTeamId } = useTeamIdAction();
1313
const navigate = useNavigate();
1414

15-
const { data, isSuccess } = $api.useQuery('get', '/api/v1/members/teams', {
15+
const { data, isSuccess } = $api.useSuspenseQuery('get', '/api/v1/members/teams', {
1616
select: (response: TeamResponse) => {
1717
return response.data;
1818
},

apps/client/src/shared/store/team.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { create } from 'zustand';
22

33
type TeamStore = {
4-
teamId: number;
4+
teamId: number | null;
55
actions: {
6-
setTeamId: (id: number) => void;
6+
setTeamId: (id: number | null) => void;
77
};
88
};
99

1010
const useTeamStore = create<TeamStore>((set) => ({
1111
teamId: Number(localStorage.getItem('teamId')),
1212

1313
actions: {
14-
setTeamId: (teamId: number) =>
14+
setTeamId: (teamId: number | null) =>
1515
set({
1616
teamId,
1717
}),

0 commit comments

Comments
 (0)