Skip to content

Commit

Permalink
fix: landingStatus 로직 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene028 committed Aug 6, 2024
1 parent 171e886 commit 45766be
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 56 deletions.
26 changes: 18 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand All @@ -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 <div>로딩중...</div>;
}

const { currentRecruitmentRound } = data;

return (
<Wrapper direction="column">
Expand Down Expand Up @@ -163,11 +173,11 @@ function App() {
<OnboardingLogo2 />
<Space height={25} />
<ApplyButton
disabled={landingStatus === 'ONBOARDING_CLOSED'}
onClick={() => navigate(getAuthRedirectPath(landingStatus))}>
{landingStatus === 'ONBOARDING_CLOSED'
? '지금은 지원 기간이 아니에요'
: '가입하기'}
disabled={!currentRecruitmentRound.period.open}
onClick={() => navigate(RoutePath.Dashboard)}>
{currentRecruitmentRound.period.open
? '가입하기'
: '지금은 지원 기간이 아니에요'}
</ApplyButton>
<Space height={40} />
</BlueSection>
Expand Down
5 changes: 0 additions & 5 deletions src/components/auth/guard/SignupAccessGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@ import { Outlet } from 'react-router-dom';

//deprecated: 추후 삭제 필요한 파일임
export default function SignupAccessGuard() {
//TODO: 추후 보안 정책에 따라 수정 필요
// if (landingStatus !== LandingStatus.Signup) {
// return <Navigate to={getAuthRedirectPath(landingStatus)} />;
// }

return <Outlet />;
}
6 changes: 0 additions & 6 deletions src/components/auth/guard/StudentVerificationAccessGuard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { Outlet } from 'react-router-dom';

export default function StudentVerificationAccessGuard() {
// const { landingStatus } = useLandingStatus();

// if (landingStatus !== LandingStatus.StudentAuthentication) {
// return <Navigate to={getAuthRedirectPath(landingStatus)} />;
// }

return <Outlet />;
}
4 changes: 2 additions & 2 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 0 additions & 3 deletions src/components/myPage/BasicUserInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
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';

import { useNavigate } from 'react-router-dom';

const BasicUserInfo = ({ member }: { member: User }) => {
const navigate = useNavigate();
const { clearLandingStatus } = useLandingStatus();

const handleLogoutClick = () => {
clearLandingStatus();
logout();

navigate('/');
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/mutation/useCreateUserBasicInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
});
Expand Down
6 changes: 0 additions & 6 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
SignUp,
Dashboard,
JoinDiscord,
UpdatedStudentVerification,
Bevy,
OnboardingNotOpened,
OnboardingClosed,
Expand Down Expand Up @@ -74,11 +73,6 @@ const router = sentryCreateBrowserRouter([
}
]
},
{
path: RoutePath.AuthenticationProcess2_UpdatedStudentVerification,
element: <StudentVerificationAccessGuard />,
children: [{ index: true, element: <UpdatedStudentVerification /> }]
},
{
path: RoutePath.AuthenticationProcess3_Signup,
element: <SignupAccessGuard />,
Expand Down
2 changes: 0 additions & 2 deletions src/routes/routePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
22 changes: 0 additions & 22 deletions src/utils/auth.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}

/**
* 쿠키 이름을 기반으로 쿠키 값을 가져옴
Expand Down
5 changes: 5 additions & 0 deletions src/utils/storage/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ export const enum StorageKeys {
AccessToken = 'access_token',
RefreshToken = 'refresh_token'
}

export const enum CookieKeys {
AccessToken = 'access',
RefreshToken = 'refresh'
}

0 comments on commit 45766be

Please sign in to comment.