Skip to content

Commit

Permalink
Merge pull request #205 from YAPP-Github/dev
Browse files Browse the repository at this point in the history
Release 0.1.13
  • Loading branch information
choisohyun authored Jul 30, 2022
2 parents e566659 + 260b629 commit 985cd3e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/components/header/MenuBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/oauth.ts
Original file line number Diff line number Diff line change
@@ -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;
};
5 changes: 0 additions & 5 deletions src/lib/api/login.ts → src/lib/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import apiClient from './index';
import { LoginResponse, LoginRequest, KakaoIdResponse } from '@/types/user';
/*
@desc
임시 아이디 비번: test1
*/

export const postJoin = async (payload: LoginRequest): Promise<LoginResponse | undefined> => {
const res = await apiClient.post('/join', payload);
Expand All @@ -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;
Expand Down
75 changes: 52 additions & 23 deletions src/pages/AgreementSurvey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand All @@ -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]);
Expand All @@ -46,27 +60,42 @@ const AgreementSurvey = () => {
};

return (
<SurveyTemplate
disableNext={!isEssentialChecked}
hasProgressBar={false}
handlePrevClick={() => meetingNavigate(Path.ChannelSurvey)}
handleNextClick={handleNextClick}
>
<Title>
약관동의를 <br />
진행해주세요.
</Title>
<FormWrapper>
<CheckBox text="전체동의" impotrant checked={isAllchecked} onChange={onCheckAll} />
<DivisionLineStyled />
{checkedList.map(({ checked, name, text }) => (
<CheckBox key={text} text={text} name={name} checked={checked} onChange={onChangeCheck} />
))}
{checkedChoiceList.map(({ checked, name, text }) => (
<CheckBox key={text} text={text} name={name} checked={checked} onChange={onChangeChoiceCheck} />
))}
</FormWrapper>
</SurveyTemplate>
<>
<SurveyTemplate
disableNext={!isEssentialChecked}
hasProgressBar={false}
handlePrevClick={() => meetingNavigate(Path.ChannelSurvey)}
handleNextClick={handleNextClick}
>
<Title>
약관동의를 <br />
진행해주세요.
</Title>
<FormWrapper>
<CheckBox text="전체동의" impotrant checked={isAllchecked} onChange={onCheckAll} />
<DivisionLineStyled />
{checkedList.map(({ checked, name, text }) => (
<CheckBox key={text} text={text} name={name} checked={checked} onChange={onChangeCheck} />
))}
{checkedChoiceList.map(({ checked, name, text }) => (
<CheckBox key={text} text={text} name={name} checked={checked} onChange={onChangeChoiceCheck} />
))}
</FormWrapper>
</SurveyTemplate>
{modal.open && (
<Modal
width={200}
height={140}
bottonName="확인"
title={modal.title}
text={modal.message}
onToggleModal={() => setModal((prev) => ({ ...prev, open: false }))}
onClick={() => {
void 0;
}}
/>
)}
</>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/TestLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 985cd3e

Please sign in to comment.