From 58b4eb6deb6c8e4f37d237a47f0b236da95b5e00 Mon Sep 17 00:00:00 2001 From: Savien/Woo Jun Han <49388937+MrMirror21@users.noreply.github.com> Date: Wed, 30 Oct 2024 01:18:53 +0900 Subject: [PATCH 1/6] =?UTF-8?q?:bug:=20fix:=20=EC=83=9D=EC=9D=BC=EA=B3=BC?= =?UTF-8?q?=20=EB=B9=84=EC=9E=90=20api=20=EB=AA=85=EC=84=B8=EC=84=9C?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=ED=98=95=EB=B3=80=ED=99=98=20?= =?UTF-8?q?#60?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Information/InformationStep.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/Information/InformationStep.tsx b/src/components/Information/InformationStep.tsx index cc1ba181..e7a044a0 100644 --- a/src/components/Information/InformationStep.tsx +++ b/src/components/Information/InformationStep.tsx @@ -13,6 +13,7 @@ import RadioButton from '@/components/Information/RadioButton'; import { InputType } from '@/types/common/input'; import BottomButtonPanel from '@/components/Common/BottomButtonPanel'; import Button from '@/components/Common/Button'; +import { formatDateToDash } from '../../utils/editResume'; const InformationStep = ({ userInfo, @@ -205,6 +206,8 @@ const InformationStep = ({ nationality: newUserInfo.nationality ?.toUpperCase() .replace(/\s/g, '_'), + birth: formatDateToDash(newUserInfo.birth as string), + visa: newUserInfo.visa?.replace('-', '_'), }, }) } From 25b4d543f8c432ce89e581f48e534c3c43cdfc40 Mon Sep 17 00:00:00 2001 From: Hyeona01 Date: Wed, 30 Oct 2024 03:23:53 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E2=9C=A8=20feat:=20nav=20bar=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EB=B3=84=20=EB=A1=9C=EC=A7=81=20=EB=B6=84=EA=B8=B0=20?= =?UTF-8?q?#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Common/Navbar.tsx | 81 ++++++++++++++++++-------------- src/constants/routes.ts | 61 ++++++++++++++++++++++++ src/router.tsx | 16 ++++++- 3 files changed, 121 insertions(+), 37 deletions(-) create mode 100644 src/constants/routes.ts diff --git a/src/components/Common/Navbar.tsx b/src/components/Common/Navbar.tsx index 5089b90a..832a2c0d 100644 --- a/src/components/Common/Navbar.tsx +++ b/src/components/Common/Navbar.tsx @@ -1,52 +1,63 @@ import { useLocation, useNavigate } from 'react-router-dom'; -import HomeIcon from '@/assets/icons/HomeIcon.svg?react'; -import SearchIcon from '@/assets/icons/NavSearchIcon.svg?react'; -import DocumentsIcon from '@/assets/icons/DocumentsIcon.svg?react'; -import ProfileIcon from '@/assets/icons/ProfileIcon.svg?react'; +import { useUserStore } from '@/store/user'; +import { UserType } from '@/constants/user'; +import { employerRoutes, userRoutes, guestRoutes } from '@/constants/routes'; const Navbar = () => { const location = useLocation(); const navigate = useNavigate(); + const { account_type } = useUserStore(); const getIconColor = (path: string) => { return location.pathname === path ? '#1E1926' : '#DCDCDC'; }; - const routes = [ - { - path: '/', - svg: HomeIcon, - }, - { - path: '/search', - svg: SearchIcon, - }, - { - path: '/application', - svg: DocumentsIcon, - }, - { - path: '/profile', - svg: ProfileIcon, - }, - ]; - return (
- {routes.map((route, index) => { - const IconComponent = route.svg; - return ( - - ); - })} + {/* 유학생 유저일 경우 nav bar */} + {account_type === UserType.USER && + userRoutes.map((route, index) => { + const IconComponent = route.svg; + return ( + + ); + })} + {/* 고용자 유저일 경우 nav bar */} + {account_type === UserType.USER && + employerRoutes.map((route, index) => { + const IconComponent = route.svg; + return ( + + ); + })} + {/* 비회원일 경우 nav bar */} + {account_type === undefined && + guestRoutes.map((route, index) => { + const IconComponent = route.svg; + return ( + + ); + })}
diff --git a/src/constants/routes.ts b/src/constants/routes.ts new file mode 100644 index 00000000..5dcfcab6 --- /dev/null +++ b/src/constants/routes.ts @@ -0,0 +1,61 @@ +import HomeIcon from '@/assets/icons/HomeIcon.svg?react'; +import SearchIcon from '@/assets/icons/NavSearchIcon.svg?react'; +import DocumentsIcon from '@/assets/icons/DocumentsIcon.svg?react'; +import ProfileIcon from '@/assets/icons/ProfileIcon.svg?react'; + +export const userRoutes = [ + { + path: '/', + svg: HomeIcon, + }, + { + path: '/search', + svg: SearchIcon, + }, + { + path: '/application', + svg: DocumentsIcon, + }, + { + path: '/profile', + svg: ProfileIcon, + }, +]; + +export const employerRoutes = [ + { + path: '/', + svg: HomeIcon, + }, + { + path: '/search', + svg: SearchIcon, + }, + { + path: '/employer/post', + svg: DocumentsIcon, + }, + { + path: '/employer/profile', + svg: ProfileIcon, + }, +]; + +export const guestRoutes = [ + { + path: '/', + svg: HomeIcon, + }, + { + path: '/search', + svg: SearchIcon, + }, + { + path: '/signin', + svg: DocumentsIcon, + }, + { + path: '/signin', + svg: ProfileIcon, + }, +]; diff --git a/src/router.tsx b/src/router.tsx index d5f1d605..d80bd439 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -39,20 +39,30 @@ import EmployerApplicantResumePage from '@/pages/Employer/ApplicantResume/Employ import EmployerApplicantResumeAcceptPage from '@/pages/Employer/ApplicantResumeAccept/EmployerApplicantResumeAcceptPage'; import AlarmPage from '@/pages/Alarm/AlarmPage'; import ChatBotPage from '@/pages/ChatBot/ChatBotPage'; +import { useUserStore } from '@/store/user'; +import { UserType } from '@/constants/user'; +import Splash from '@/components/Splash/Splash'; +import EmployerSignupPage from './pages/Employer/signup/EmployerSignupPage'; const Layout = () => { const location = useLocation(); + const { account_type } = useUserStore(); // Nav bar 컴포넌트가 랜딩되는 페이지 - const showNavbarPaths = ['/', '/profile', '/search', '/application']; + const showNavbarPaths = () => { + if (account_type === UserType.OWNER) { + return ['/', '/search', '/employer/post', '/employer/profile']; + } else return ['/', '/search', '/application', '/profile']; + }; - const shouldShowNavbar = showNavbarPaths.includes(location.pathname); + const shouldShowNavbar = showNavbarPaths().includes(location.pathname); return ( <> {shouldShowNavbar && } + {console.log(account_type)} ); }; @@ -63,6 +73,7 @@ const Router = () => { }> } /> + } /> } /> } /> } /> @@ -102,6 +113,7 @@ const Router = () => { } /> } /> + } /> } From 20f1682c139ce35f8c9e001e13da3749381a9ce6 Mon Sep 17 00:00:00 2001 From: Hyeona01 Date: Wed, 30 Oct 2024 03:27:08 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E2=9C=A8=20feat:=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20API=20=ED=8F=BC=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=B0=8F=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=ED=98=95=EC=8B=9D=20=ED=86=B5=EC=9D=BC=20#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Signin/SigninInputSection.tsx | 7 +- src/hooks/api/useAuth.ts | 85 ++++++++++---------- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/components/Signin/SigninInputSection.tsx b/src/components/Signin/SigninInputSection.tsx index 99a4949a..bcb1c699 100644 --- a/src/components/Signin/SigninInputSection.tsx +++ b/src/components/Signin/SigninInputSection.tsx @@ -31,7 +31,12 @@ const SigninInputSection = () => { // ====== Sign in API ======= const handleSubmit = async () => { - signIn({ serial_id: idValue, password: passwordValue }); + // signIn({ serial_id: idValue, password: passwordValue }); + const formData = new FormData(); + formData.append('serial_id', idValue); + formData.append('password', passwordValue); + + signIn(formData); }; // 모든 필드의 유효성 검사 후, Sign In 버튼 활성화 diff --git a/src/hooks/api/useAuth.ts b/src/hooks/api/useAuth.ts index 988b6a7f..d5fc4182 100644 --- a/src/hooks/api/useAuth.ts +++ b/src/hooks/api/useAuth.ts @@ -27,8 +27,8 @@ import { } from '@/utils/auth'; import { useNavigate } from 'react-router-dom'; import { useMutation, useQuery } from '@tanstack/react-query'; -import { RESTYPE } from '@/types/api/common'; import { useEmailTryCountStore } from '@/store/signup'; +import { useUserStore } from '@/store/user'; /** * 로그인 프로세스를 처리하는 커스텀 훅 @@ -59,12 +59,10 @@ export const useSignIn = () => { const navigate = useNavigate(); return useMutation({ mutationFn: signIn, - onSuccess: (data: RESTYPE) => { - if (data.success) { - setAccessToken(data.data.access_token); - setRefreshToken(data.data.refresh_token); - navigate('/splash'); - } + onSuccess: (data) => { + setAccessToken(data.access_token); + setRefreshToken(data.refresh_token); + navigate('/splash'); }, onError: () => { navigate('/signin'); @@ -75,14 +73,18 @@ export const useSignIn = () => { // 1.2 사용자 로그아웃 훅 export const useLogout = () => { const navigate = useNavigate(); + const { updateAccountType, updateName } = useUserStore(); return useMutation({ mutationFn: logout, - onSuccess: (data: RESTYPE) => { - if (data.success) { - deleteAccessToken(); - deleteRefreshToken(); - navigate('/splash'); - } + onSuccess: () => { + // 토큰 삭제 + deleteAccessToken(); + deleteRefreshToken(); + // 유저 타입 전역 변수 초기화 + updateAccountType(undefined); + updateName(''); + // 스플래시 이동 + navigate('/splash'); }, onError: () => { navigate('/profile'); @@ -92,13 +94,13 @@ export const useLogout = () => { // 1.3 JWT 재발급 훅 export const useReIssueToken = () => { + const navigate = useNavigate(); return useMutation({ mutationFn: reIssueToken, - onSuccess: (data: RESTYPE) => { - if (data.success) { - setAccessToken(data.data.access_token); - setRefreshToken(data.data.refresh_token); - } + onSuccess: (data: SignInResponse) => { + setAccessToken(data.access_token); + setRefreshToken(data.refresh_token); + navigate('/splash'); // 재발급 후 유형 확인 }, }); }; @@ -131,10 +133,8 @@ export const useGetUserType = () => { export const useTempSignUp = () => { return useMutation({ mutationFn: tempSignUp, - onSuccess: (data: RESTYPE) => { - if (!data.success) { - console.log('임시 회원가입 실패 : ', data.error?.message); - } + onError: (error) => { + console.log('임시 회원가입 실패 : ', error.message); }, }); }; @@ -144,12 +144,10 @@ export const useSignUp = () => { const navigate = useNavigate(); return useMutation({ mutationFn: signUp, - onSuccess: (data: RESTYPE) => { - if (data.success) { - deleteTemporaryToken(); - setAccessToken(data.data.access_token); - setRefreshToken(data.data.refresh_token); - } + onSuccess: (data: SignInResponse) => { + deleteTemporaryToken(); + setAccessToken(data.access_token); + setRefreshToken(data.refresh_token); }, onError: () => { navigate('/'); @@ -162,11 +160,9 @@ export const usePatchAuthentication = () => { const navigate = useNavigate(); return useMutation({ mutationFn: patchAuthentication, - onSuccess: (data: RESTYPE) => { - if (data.success) { - setTemporaryToken(data.data.temporary_token); - navigate('/information'); - } + onSuccess: (data: AuthenticationResponse) => { + setTemporaryToken(data.temporary_token); + navigate('/information'); }, onError: (error) => { console.log(error); @@ -180,11 +176,9 @@ export const useReIssueAuthentication = () => { const { updateTryCnt } = useEmailTryCountStore(); return useMutation({ mutationFn: reIssueAuthentication, - onSuccess: (data: RESTYPE) => { - if (data.success) { - // 이메일 재발송 횟수 업데이트 - updateTryCnt(data.data.try_cnt); - } + onSuccess: (data: TempSignUpResponse) => { + // 이메일 재발송 횟수 업데이트 + updateTryCnt(data.try_cnt); }, onError: () => { navigate('/signup'); @@ -195,13 +189,18 @@ export const useReIssueAuthentication = () => { // 2.9 탈퇴하기 훅 export const useWithdraw = () => { const navigate = useNavigate(); + const { updateAccountType, updateName } = useUserStore(); return useMutation({ mutationFn: withdraw, - onSuccess: (data: RESTYPE) => { - if (data.success) { - deleteAccessToken(); - deleteRefreshToken(); - } + onSuccess: () => { + // 토큰 삭제 + deleteAccessToken(); + deleteRefreshToken(); + // 유저 타입 전역 변수 초기화 + updateAccountType(undefined); + updateName(''); + // 스플래시 이동 + navigate('/splash'); }, onError: () => { navigate('/splash'); From 63f5ce4406a7c8ee33acf7d080416e7a14cd92b8 Mon Sep 17 00:00:00 2001 From: Hyeona01 Date: Wed, 30 Oct 2024 05:41:52 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=90=9B=20fix:=20visa=20=ED=98=95=20?= =?UTF-8?q?=EB=B3=80=ED=99=98=20#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Information/InformationStep.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Information/InformationStep.tsx b/src/components/Information/InformationStep.tsx index e7a044a0..27db9dce 100644 --- a/src/components/Information/InformationStep.tsx +++ b/src/components/Information/InformationStep.tsx @@ -207,7 +207,7 @@ const InformationStep = ({ ?.toUpperCase() .replace(/\s/g, '_'), birth: formatDateToDash(newUserInfo.birth as string), - visa: newUserInfo.visa?.replace('-', '_'), + visa: newUserInfo.visa?.replace(/-/g, '_'), }, }) } From 116d12457646e4f0a44d9fd4371d7de8717c9b43 Mon Sep 17 00:00:00 2001 From: Hyeona01 Date: Wed, 30 Oct 2024 06:07:51 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E2=9C=A8=20feat:=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=ED=9B=84=20=EC=9C=A0=EC=A0=80=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 2 +- src/components/Common/Navbar.tsx | 2 +- src/components/Splash/Splash.tsx | 1 + src/hooks/api/useAuth.ts | 28 +++++++++++++++------------- src/router.tsx | 1 - src/types/api/auth.ts | 5 +---- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index bcb5c7e0..3a43e413 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -49,7 +49,7 @@ function createInstance(type: string) { baseURL: type === 'kakao' ? import.meta.env.VITE_APP_KAKAO_API_BASE_URL - : import.meta.env.VITE_APP_API_URL, + : import.meta.env.VITE_APP_API_GIGGLE_API_BASE_URL, }); return setInterceptors(instance, type); } diff --git a/src/components/Common/Navbar.tsx b/src/components/Common/Navbar.tsx index 832a2c0d..900e9f35 100644 --- a/src/components/Common/Navbar.tsx +++ b/src/components/Common/Navbar.tsx @@ -31,7 +31,7 @@ const Navbar = () => { ); })} {/* 고용자 유저일 경우 nav bar */} - {account_type === UserType.USER && + {account_type === UserType.OWNER && employerRoutes.map((route, index) => { const IconComponent = route.svg; return ( diff --git a/src/components/Splash/Splash.tsx b/src/components/Splash/Splash.tsx index 3b93e4d2..3213a1b1 100644 --- a/src/components/Splash/Splash.tsx +++ b/src/components/Splash/Splash.tsx @@ -65,6 +65,7 @@ const Splash = () => { } else { // UserTypeResponse가 정의되지 않은 경우 setGuest(); + return; } } } catch (error) { diff --git a/src/hooks/api/useAuth.ts b/src/hooks/api/useAuth.ts index d5fc4182..376372be 100644 --- a/src/hooks/api/useAuth.ts +++ b/src/hooks/api/useAuth.ts @@ -29,6 +29,7 @@ import { useNavigate } from 'react-router-dom'; import { useMutation, useQuery } from '@tanstack/react-query'; import { useEmailTryCountStore } from '@/store/signup'; import { useUserStore } from '@/store/user'; +import { RESTYPE } from '@/types/api/common'; /** * 로그인 프로세스를 처리하는 커스텀 훅 @@ -59,9 +60,9 @@ export const useSignIn = () => { const navigate = useNavigate(); return useMutation({ mutationFn: signIn, - onSuccess: (data) => { - setAccessToken(data.access_token); - setRefreshToken(data.refresh_token); + onSuccess: (data: RESTYPE) => { + setAccessToken(data.data.access_token); + setRefreshToken(data.data.refresh_token); navigate('/splash'); }, onError: () => { @@ -97,9 +98,9 @@ export const useReIssueToken = () => { const navigate = useNavigate(); return useMutation({ mutationFn: reIssueToken, - onSuccess: (data: SignInResponse) => { - setAccessToken(data.access_token); - setRefreshToken(data.refresh_token); + onSuccess: (data: RESTYPE) => { + setAccessToken(data.data.access_token); + setRefreshToken(data.data.refresh_token); navigate('/splash'); // 재발급 후 유형 확인 }, }); @@ -144,10 +145,11 @@ export const useSignUp = () => { const navigate = useNavigate(); return useMutation({ mutationFn: signUp, - onSuccess: (data: SignInResponse) => { + onSuccess: (data: RESTYPE) => { + console.log(data); deleteTemporaryToken(); - setAccessToken(data.access_token); - setRefreshToken(data.refresh_token); + setAccessToken(data.data.access_token); + setRefreshToken(data.data.refresh_token); }, onError: () => { navigate('/'); @@ -160,8 +162,8 @@ export const usePatchAuthentication = () => { const navigate = useNavigate(); return useMutation({ mutationFn: patchAuthentication, - onSuccess: (data: AuthenticationResponse) => { - setTemporaryToken(data.temporary_token); + onSuccess: (data: RESTYPE) => { + setTemporaryToken(data.data.temporary_token); navigate('/information'); }, onError: (error) => { @@ -176,9 +178,9 @@ export const useReIssueAuthentication = () => { const { updateTryCnt } = useEmailTryCountStore(); return useMutation({ mutationFn: reIssueAuthentication, - onSuccess: (data: TempSignUpResponse) => { + onSuccess: (data: RESTYPE) => { // 이메일 재발송 횟수 업데이트 - updateTryCnt(data.try_cnt); + updateTryCnt(data.data.try_cnt); }, onError: () => { navigate('/signup'); diff --git a/src/router.tsx b/src/router.tsx index d80bd439..95b622f6 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -62,7 +62,6 @@ const Layout = () => { {shouldShowNavbar && } - {console.log(account_type)} ); }; diff --git a/src/types/api/auth.ts b/src/types/api/auth.ts index 4229c686..14a28933 100644 --- a/src/types/api/auth.ts +++ b/src/types/api/auth.ts @@ -1,10 +1,7 @@ import { UserType } from '@/constants/user'; import { Address, Language, UserInfo } from '@/types/api/users'; -export type SignInRequest = { - serial_id: string; - password: string; -}; +export type SignInRequest = FormData; export type SignInResponse = { access_token: string; From 2addd907ae0609d1e7497fd326ec3bdf7e8c0695 Mon Sep 17 00:00:00 2001 From: Hyeona01 Date: Wed, 30 Oct 2024 06:12:19 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=EB=94=94=EB=B2=84?= =?UTF-8?q?=EA=B9=85=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C=20#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/api/useAuth.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hooks/api/useAuth.ts b/src/hooks/api/useAuth.ts index 376372be..815f0dbc 100644 --- a/src/hooks/api/useAuth.ts +++ b/src/hooks/api/useAuth.ts @@ -146,7 +146,6 @@ export const useSignUp = () => { return useMutation({ mutationFn: signUp, onSuccess: (data: RESTYPE) => { - console.log(data); deleteTemporaryToken(); setAccessToken(data.data.access_token); setRefreshToken(data.data.refresh_token);