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/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/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/AgreementSurvey.tsx b/src/pages/AgreementSurvey.tsx index 93aed0b..87f0e9f 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,17 +21,30 @@ 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); const code = searchParams.get('code') ?? ''; + if (!code) return; + getOauthKakaoAge({ code, type: matchMeeting ? 'meeting' : 'dating' }) .then((response) => { console.log(response); - meetingNavigate(Path.KakaoIdSurvey); + if (response) { + meetingNavigate(Path.KakaoIdSurvey); + return; + } + setModal({ + open: true, + title: '성인 인증 필요', + message: + "설정 > 개인/ 보안> 카카오계정> 내 정보 관리> '생일을 알려주세요' 선택> '프로필 정보 추가 수집 동의' 선택> 생일 설정> 확인 후 연령대 정보 제공 동의를 눌러주세요.", + }); }) .catch((e) => { + setModal((prev) => ({ ...prev, open: true })); console.error(e); }); }, [location]); @@ -46,27 +60,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; + }} + /> + )} + ); }; 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';