From 39380b6d0ac23ae83d51ad2d3835108d033f14ed Mon Sep 17 00:00:00 2001 From: Jiyoung Kim Date: Sat, 30 Jul 2022 13:51:30 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20login.ts=20->=20user.ts=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/header/MenuBlock.tsx | 2 +- src/lib/api/{login.ts => user.ts} | 5 ----- src/pages/TestLogin.tsx | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) rename src/lib/api/{login.ts => user.ts} (90%) diff --git a/src/components/header/MenuBlock.tsx b/src/components/header/MenuBlock.tsx index 5e2f818..0a8979b 100644 --- a/src/components/header/MenuBlock.tsx +++ b/src/components/header/MenuBlock.tsx @@ -4,7 +4,7 @@ import { palette } from '@/lib/styles/palette'; import styled from 'styled-components'; import DatingInfoBox from './DatingInfoBox'; import MeetingInfoBox from './MeetingInfoBox'; -import { postLogout, postWithdrawal } from '@/lib/api/login'; +import { postLogout, postWithdrawal } from '@/lib/api/user'; import { useToggle } from '@/hooks/common'; import { Modal } from '../base'; interface MenuBlockProps { diff --git a/src/lib/api/login.ts b/src/lib/api/user.ts similarity index 90% rename from src/lib/api/login.ts rename to src/lib/api/user.ts index 040f14b..90a4398 100644 --- a/src/lib/api/login.ts +++ b/src/lib/api/user.ts @@ -1,9 +1,5 @@ import apiClient from './index'; import { LoginResponse, LoginRequest, KakaoIdResponse } from '@/types/user'; -/* - @desc - 임시 아이디 비번: test1 -*/ export const postJoin = async (payload: LoginRequest): Promise => { const res = await apiClient.post('/join', payload); @@ -21,7 +17,6 @@ export const getKakaoId = async () => { return res.data; }; -/* @FIXME: 나중에 user.ts로 바꾸기 */ export const postLogout = async () => { const res = await apiClient.post('/logout'); return res.data; diff --git a/src/pages/TestLogin.tsx b/src/pages/TestLogin.tsx index 5e0f6bc..3b4b613 100644 --- a/src/pages/TestLogin.tsx +++ b/src/pages/TestLogin.tsx @@ -6,7 +6,7 @@ import { Title } from '@/lib/styles/styledComponents'; import { palette } from '@/lib/styles/palette'; import { LoginForm } from '@/components/testLogin'; import { LoginRequest } from '@/types/user'; -import { postLogin } from '@/lib/api/login'; +import { postLogin } from '@/lib/api/user'; import Cookies from 'js-cookie'; import { useNavigate } from 'react-router-dom'; import { useToggle } from '@/hooks/common'; From 372f1158703493c03b8791cf88ca471e99b8d914 Mon Sep 17 00:00:00 2001 From: choisohyun Date: Sat, 30 Jul 2022 15:41:27 +0900 Subject: [PATCH 2/5] fix: url error --- src/lib/api/oauth.ts | 2 +- src/pages/AgreementSurvey.tsx | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib/api/oauth.ts b/src/lib/api/oauth.ts index f45e697..4ccd5fc 100644 --- a/src/lib/api/oauth.ts +++ b/src/lib/api/oauth.ts @@ -1,6 +1,6 @@ import apiClient from '@/lib/api/index'; export const getOauthKakaoAge = async (params: { code: string; type: 'dating' | 'meeting' }) => { - const res = await apiClient.get(`/oauth/kakao/age&code=${params.code}?type=${params.type}`); + const res = await apiClient.get(`/oauth/kakao/age?code=${params.code}&type=${params.type}`); return res.data; }; diff --git a/src/pages/AgreementSurvey.tsx b/src/pages/AgreementSurvey.tsx index 93aed0b..e326445 100644 --- a/src/pages/AgreementSurvey.tsx +++ b/src/pages/AgreementSurvey.tsx @@ -25,14 +25,15 @@ const AgreementSurvey = () => { const searchParams = new URLSearchParams(location.search); const code = searchParams.get('code') ?? ''; - getOauthKakaoAge({ code, type: matchMeeting ? 'meeting' : 'dating' }) - .then((response) => { - console.log(response); - meetingNavigate(Path.KakaoIdSurvey); - }) - .catch((e) => { - console.error(e); - }); + code && + getOauthKakaoAge({ code, type: matchMeeting ? 'meeting' : 'dating' }) + .then((response) => { + console.log(response); + meetingNavigate(Path.KakaoIdSurvey); + }) + .catch((e) => { + console.error(e); + }); }, [location]); const handleNextClick = () => { From 156ab36e5446c84839e19751fc9dd30862a1ea99 Mon Sep 17 00:00:00 2001 From: choisohyun Date: Sat, 30 Jul 2022 15:42:50 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=EC=9D=91=EB=8B=B5=20=EC=95=8C?= =?UTF-8?q?=EB=9F=BF=20=EB=AA=A8=EB=8B=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AgreementSurvey.tsx | 73 ++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/src/pages/AgreementSurvey.tsx b/src/pages/AgreementSurvey.tsx index e326445..6d3e69e 100644 --- a/src/pages/AgreementSurvey.tsx +++ b/src/pages/AgreementSurvey.tsx @@ -3,7 +3,7 @@ import { SurveyTemplate } from '@/components/domain/survey'; import useAgreementCheck from '@/hooks/agreement/useAgreementCheck'; import { palette } from '@/lib/styles/palette'; import { Title } from '@/lib/styles/styledComponents'; -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import styled from 'styled-components'; import { FormWrapper } from './AuthMail'; import Path from '@/router/Path'; @@ -12,6 +12,7 @@ import { useDatingNavigate, useMeetingNavigate } from '@/hooks/common/useNavigat import { useMeetingSessionState, useDatingSessionState } from '@/hooks/common'; import { goKakaoLogin } from '@/utils/goKakaoLogin'; import { getOauthKakaoAge } from '@/lib/api/oauth'; +import { Modal } from '@/components/base'; const AgreementSurvey = () => { const location = useLocation(); @@ -20,6 +21,7 @@ const AgreementSurvey = () => { const { initMeetingState, setMeetingData } = useMeetingSessionState(); const { initDatingState, setDatingData } = useDatingSessionState(); const { checkedList, checkedChoiceList, onChangeCheck, onChangeChoiceCheck, onCheckAll, isEssentialChecked, isAllchecked } = useAgreementCheck(); + const [modal, setModal] = useState({ open: false, title: '알림', message: '에러가 발생했습니다😭 다시한번 시도해 주세요!' }); useEffect(() => { const searchParams = new URLSearchParams(location.search); @@ -29,9 +31,19 @@ const AgreementSurvey = () => { getOauthKakaoAge({ code, type: matchMeeting ? 'meeting' : 'dating' }) .then((response) => { console.log(response); - meetingNavigate(Path.KakaoIdSurvey); + if (response) { + meetingNavigate(Path.KakaoIdSurvey); + } else { + setModal({ + open: true, + title: '성인 인증 필요', + message: + "설정 > 개인/ 보안> 카카오계정> 내 정보 관리> '생일을 알려주세요' 선택> '프로필 정보 추가 수집 동의' 선택> 생일 설정> 확인 후 연령대 정보 제공 동의", + }); + } }) .catch((e) => { + setModal((prev) => ({ ...prev, open: true })); console.error(e); }); }, [location]); @@ -47,27 +59,42 @@ const AgreementSurvey = () => { }; return ( - meetingNavigate(Path.ChannelSurvey)} - handleNextClick={handleNextClick} - > - - 약관동의를 <br /> - 진행해주세요. - - - - - {checkedList.map(({ checked, name, text }) => ( - - ))} - {checkedChoiceList.map(({ checked, name, text }) => ( - - ))} - - + <> + meetingNavigate(Path.ChannelSurvey)} + handleNextClick={handleNextClick} + > + + 약관동의를 <br /> + 진행해주세요. + + + + + {checkedList.map(({ checked, name, text }) => ( + + ))} + {checkedChoiceList.map(({ checked, name, text }) => ( + + ))} + + + {modal.open && ( + setModal((prev) => ({ ...prev, open: false }))} + onClick={() => { + void 0; + }} + /> + )} + ); }; From 4082399a96a12753967e4c9f6d2bf1e8fa868375 Mon Sep 17 00:00:00 2001 From: choisohyun Date: Sat, 30 Jul 2022 15:42:58 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=EB=AC=B8=EA=B5=AC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AgreementSurvey.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/AgreementSurvey.tsx b/src/pages/AgreementSurvey.tsx index 6d3e69e..0de4cdc 100644 --- a/src/pages/AgreementSurvey.tsx +++ b/src/pages/AgreementSurvey.tsx @@ -38,7 +38,7 @@ const AgreementSurvey = () => { open: true, title: '성인 인증 필요', message: - "설정 > 개인/ 보안> 카카오계정> 내 정보 관리> '생일을 알려주세요' 선택> '프로필 정보 추가 수집 동의' 선택> 생일 설정> 확인 후 연령대 정보 제공 동의", + "설정 > 개인/ 보안> 카카오계정> 내 정보 관리> '생일을 알려주세요' 선택> '프로필 정보 추가 수집 동의' 선택> 생일 설정> 확인 후 연령대 정보 제공 동의를 눌러주세요.", }); } }) From 4cbe1513332311c7cf5a3d5baefe0a4adad0c66f Mon Sep 17 00:00:00 2001 From: choisohyun Date: Sat, 30 Jul 2022 15:44:51 +0900 Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20depth=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AgreementSurvey.tsx | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/pages/AgreementSurvey.tsx b/src/pages/AgreementSurvey.tsx index 0de4cdc..87f0e9f 100644 --- a/src/pages/AgreementSurvey.tsx +++ b/src/pages/AgreementSurvey.tsx @@ -27,25 +27,26 @@ const AgreementSurvey = () => { const searchParams = new URLSearchParams(location.search); const code = searchParams.get('code') ?? ''; - code && - getOauthKakaoAge({ code, type: matchMeeting ? 'meeting' : 'dating' }) - .then((response) => { - console.log(response); - if (response) { - meetingNavigate(Path.KakaoIdSurvey); - } else { - setModal({ - open: true, - title: '성인 인증 필요', - message: - "설정 > 개인/ 보안> 카카오계정> 내 정보 관리> '생일을 알려주세요' 선택> '프로필 정보 추가 수집 동의' 선택> 생일 설정> 확인 후 연령대 정보 제공 동의를 눌러주세요.", - }); - } - }) - .catch((e) => { - setModal((prev) => ({ ...prev, open: true })); - console.error(e); + if (!code) return; + + getOauthKakaoAge({ code, type: matchMeeting ? 'meeting' : 'dating' }) + .then((response) => { + console.log(response); + if (response) { + meetingNavigate(Path.KakaoIdSurvey); + return; + } + setModal({ + open: true, + title: '성인 인증 필요', + message: + "설정 > 개인/ 보안> 카카오계정> 내 정보 관리> '생일을 알려주세요' 선택> '프로필 정보 추가 수집 동의' 선택> 생일 설정> 확인 후 연령대 정보 제공 동의를 눌러주세요.", }); + }) + .catch((e) => { + setModal((prev) => ({ ...prev, open: true })); + console.error(e); + }); }, [location]); const handleNextClick = () => {