Skip to content

Commit

Permalink
Merge pull request #212 from TheUpperPart/Feat/#210
Browse files Browse the repository at this point in the history
Feat/#210 로그아웃시 소개 페이지로 이동
  • Loading branch information
navyjeongs authored Nov 1, 2023
2 parents c1f6087 + 8cf671a commit b821982
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Header = () => {
Cookies.remove('accessToken');
Cookies.remove('refreshToken');

await profileContext?.refetchProfile();
router.push('/');
} catch (error) {
alert('로그아웃에 실패하였습니다.\n다시 시도해주세요');
Expand Down
5 changes: 5 additions & 0 deletions src/components/providers/ProfileProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@ const ProfileProvider = ({ children }: ProfileProviderProps) => {
}
}, [profileQuery.data]);

const refetchProfile = async () => {
await profileQuery.refetch();
};

return (
<ProfileContext.Provider
value={{
profile,
setProfile,
status: profileQuery.status,
isInitialLoading: profileQuery.isInitialLoading,
refetchProfile,
}}
>
{children}
Expand Down
1 change: 1 addition & 0 deletions src/contexts/ProfileContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface ProfileState {
setProfile: React.Dispatch<React.SetStateAction<Profile | null>>;
status: 'loading' | 'error' | 'success';
isInitialLoading: boolean;
refetchProfile: () => Promise<void>;
}

const ProfileContext = createContext<ProfileState | null>(null);
Expand Down

0 comments on commit b821982

Please sign in to comment.