From 45766bef264cf62241c22ef1e5943c8a047a00bb Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Tue, 6 Aug 2024 15:39:38 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20landingStatus=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 26 +++++++++++++------ .../auth/guard/SignupAccessGuard.tsx | 5 ---- .../guard/StudentVerificationAccessGuard.tsx | 6 ----- src/components/layout/Header.tsx | 4 +-- src/components/myPage/BasicUserInfo.tsx | 3 --- src/hooks/mutation/useCreateUserBasicInfo.ts | 2 -- src/routes/index.tsx | 6 ----- src/routes/routePath.ts | 2 -- src/utils/auth.ts | 22 ---------------- src/utils/storage/key.ts | 5 ++++ 10 files changed, 25 insertions(+), 56 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index be0eca6..de0de20 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,6 +4,8 @@ import { OnboardingLogo1, OnboardingLogo2 } from '@/assets/Onboarding'; +import { useQuery } from '@tanstack/react-query'; +import memberApi from './apis/member/memberApi'; import { Flex, Space, Text } from '@/components/common/Wrapper'; import { InformationBox } from '@/components/onboarding/InformationBox'; import { color, typography } from 'wowds-tokens'; @@ -12,9 +14,8 @@ import styled from '@emotion/styled'; import { css } from '@emotion/react'; import GlobalSize from '@/constants/globalSize'; import { useNavigate } from 'react-router-dom'; -import { getAuthRedirectPath } from '@/utils/auth'; import 'react-toastify/dist/ReactToastify.css'; -import useLandingStatus from '@/hooks/zustand/useLandingStatus'; +import RoutePath from './routes/routePath'; const IMG_SRC = [ '/onboarding/1.png', @@ -29,7 +30,16 @@ const IMG_SRC = [ function App() { const navigate = useNavigate(); - const { landingStatus } = useLandingStatus(); + const { data } = useQuery({ + queryKey: ['member'], + queryFn: memberApi.GET_DASHBOARD + }); + + if (!data) { + return
로딩중...
; + } + + const { currentRecruitmentRound } = data; return ( @@ -163,11 +173,11 @@ function App() { navigate(getAuthRedirectPath(landingStatus))}> - {landingStatus === 'ONBOARDING_CLOSED' - ? '지금은 지원 기간이 아니에요' - : '가입하기'} + disabled={!currentRecruitmentRound.period.open} + onClick={() => navigate(RoutePath.Dashboard)}> + {currentRecruitmentRound.period.open + ? '가입하기' + : '지금은 지원 기간이 아니에요'} diff --git a/src/components/auth/guard/SignupAccessGuard.tsx b/src/components/auth/guard/SignupAccessGuard.tsx index 94c42ac..e06598d 100644 --- a/src/components/auth/guard/SignupAccessGuard.tsx +++ b/src/components/auth/guard/SignupAccessGuard.tsx @@ -2,10 +2,5 @@ import { Outlet } from 'react-router-dom'; //deprecated: 추후 삭제 필요한 파일임 export default function SignupAccessGuard() { - //TODO: 추후 보안 정책에 따라 수정 필요 - // if (landingStatus !== LandingStatus.Signup) { - // return ; - // } - return ; } diff --git a/src/components/auth/guard/StudentVerificationAccessGuard.tsx b/src/components/auth/guard/StudentVerificationAccessGuard.tsx index 7ec9007..8fe903a 100644 --- a/src/components/auth/guard/StudentVerificationAccessGuard.tsx +++ b/src/components/auth/guard/StudentVerificationAccessGuard.tsx @@ -1,11 +1,5 @@ import { Outlet } from 'react-router-dom'; export default function StudentVerificationAccessGuard() { - // const { landingStatus } = useLandingStatus(); - - // if (landingStatus !== LandingStatus.StudentAuthentication) { - // return ; - // } - return ; } diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 3b05518..ddb382f 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -7,17 +7,17 @@ import useLandingStatus from '@/hooks/zustand/useLandingStatus'; import RoutePath from '@/routes/routePath'; import { color } from 'wowds-tokens'; import { media } from '@/styles'; -import { getAuthRedirectPath } from '@/utils/auth'; import styled from '@emotion/styled'; import { useLocation, useNavigate } from 'react-router-dom'; +//TODO: 백엔드 로그인 로직 수정 이후 반영 필요 export default function Header() { const navigation = useNavigate(); const { pathname } = useLocation(); const { landingStatus } = useLandingStatus(); const handleClick = () => { - navigation(getAuthRedirectPath(landingStatus)); + navigation(RoutePath.Dashboard); }; return ( diff --git a/src/components/myPage/BasicUserInfo.tsx b/src/components/myPage/BasicUserInfo.tsx index 64fb95b..5b1b5ae 100644 --- a/src/components/myPage/BasicUserInfo.tsx +++ b/src/components/myPage/BasicUserInfo.tsx @@ -1,6 +1,5 @@ import { Flex, Text } from '@/components/common/Wrapper'; import { User } from '@/types/user'; -import useLandingStatus from '@/hooks/zustand/useLandingStatus'; import { logout } from '@/utils/auth'; import { typography, color } from 'wowds-tokens'; @@ -8,10 +7,8 @@ import { useNavigate } from 'react-router-dom'; const BasicUserInfo = ({ member }: { member: User }) => { const navigate = useNavigate(); - const { clearLandingStatus } = useLandingStatus(); const handleLogoutClick = () => { - clearLandingStatus(); logout(); navigate('/'); diff --git a/src/hooks/mutation/useCreateUserBasicInfo.ts b/src/hooks/mutation/useCreateUserBasicInfo.ts index 6588c6c..499dc1e 100644 --- a/src/hooks/mutation/useCreateUserBasicInfo.ts +++ b/src/hooks/mutation/useCreateUserBasicInfo.ts @@ -5,12 +5,10 @@ import { useNavigate } from 'react-router-dom'; export default function useCreateUserBasicInfo() { const navigation = useNavigate(); - // const { updateLandingStatue } = useLandingStatus(); const { mutate: createBasicInfo, ...rest } = useMutation({ mutationFn: createBasicInfoApi.BASIC_INFO, onSuccess: () => { - // updateLandingStatue(LandingStatus.Dashboard); navigation(RoutePath.Dashboard, { replace: true }); } }); diff --git a/src/routes/index.tsx b/src/routes/index.tsx index c946584..1faec12 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -20,7 +20,6 @@ import { SignUp, Dashboard, JoinDiscord, - UpdatedStudentVerification, Bevy, OnboardingNotOpened, OnboardingClosed, @@ -74,11 +73,6 @@ const router = sentryCreateBrowserRouter([ } ] }, - { - path: RoutePath.AuthenticationProcess2_UpdatedStudentVerification, - element: , - children: [{ index: true, element: }] - }, { path: RoutePath.AuthenticationProcess3_Signup, element: , diff --git a/src/routes/routePath.ts b/src/routes/routePath.ts index c5eb9fc..292c5b4 100644 --- a/src/routes/routePath.ts +++ b/src/routes/routePath.ts @@ -15,8 +15,6 @@ const RoutePath = { AuthenticationProcess1_GithubSignin: '/auth', AuthenticationProcess2_StudentVerification: '/student-verification', - AuthenticationProcess2_UpdatedStudentVerification: - '/updated-student-verification', AuthenticationProcess3_Signup: '/signup', AuthGithubLoginRedirect: `${BASE_URL}/oauth2/authorization/github`, diff --git a/src/utils/auth.ts b/src/utils/auth.ts index a12cb7c..cc23e30 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1,26 +1,4 @@ -import LandingStatus from '@/constants/landingStatus'; import useAuthToken from '@/hooks/auth/useAuthToken'; -import RoutePath from '@/routes/routePath'; - -/** - * 깃허브 로그인 성공 시 header에서 추출한 landing status 통해 이동할 페이지 반환 - */ -export function getAuthRedirectPath(landingStatus: string | null | undefined) { - switch (landingStatus) { - case LandingStatus.StudentAuthentication: - return RoutePath.AuthenticationProcess2_StudentVerification; - case LandingStatus.Signup: - return RoutePath.AuthenticationProcess3_Signup; - case LandingStatus.Dashboard: - return RoutePath.Dashboard; - case LandingStatus.OnboardingNotOpened: - return RoutePath.OnboardingNotOpened; - case LandingStatus.OnboardingClosed: - return RoutePath.OnboardingClosed; - default: - return RoutePath.AuthenticationProcess1_GithubSignin; - } -} /** * 쿠키 이름을 기반으로 쿠키 값을 가져옴 diff --git a/src/utils/storage/key.ts b/src/utils/storage/key.ts index 5e7ebcf..fa7413f 100644 --- a/src/utils/storage/key.ts +++ b/src/utils/storage/key.ts @@ -2,3 +2,8 @@ export const enum StorageKeys { AccessToken = 'access_token', RefreshToken = 'refresh_token' } + +export const enum CookieKeys { + AccessToken = 'access', + RefreshToken = 'refresh' +}