Skip to content

Commit e8db3e3

Browse files
committed
약관
1 parent 63d9e4c commit e8db3e3

File tree

3 files changed

+81
-16
lines changed

3 files changed

+81
-16
lines changed

src/constants/terms/index.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { PRIVACY_POLICY_CONTENT, PRIVACY_POLICY_TITLE } from './privacyPolicy';
2+
import { TERMS_OF_SERVICE_CONTENT, TERMS_OF_SERVICE_TITLE } from './termsOfService';
3+
4+
export const TERM_ID = {
5+
PRIVACY_POLICY: 1,
6+
TERMS_OF_SERVICE: 2,
7+
} as const;
8+
9+
export type TermId = (typeof TERM_ID)[keyof typeof TERM_ID];
10+
11+
export type TermContent = {
12+
id: TermId;
13+
title: string;
14+
content: string;
15+
};
16+
17+
export const TERM_BY_ID: Record<TermId, TermContent> = {
18+
[TERM_ID.PRIVACY_POLICY]: {
19+
id: TERM_ID.PRIVACY_POLICY,
20+
title: PRIVACY_POLICY_TITLE,
21+
content: PRIVACY_POLICY_CONTENT,
22+
},
23+
[TERM_ID.TERMS_OF_SERVICE]: {
24+
id: TERM_ID.TERMS_OF_SERVICE,
25+
title: TERMS_OF_SERVICE_TITLE,
26+
content: TERMS_OF_SERVICE_CONTENT,
27+
},
28+
};
29+
30+
export type SignUpTerm = {
31+
id: TermId;
32+
title: string;
33+
required: boolean;
34+
};
35+
36+
export const SIGNUP_TERMS: SignUpTerm[] = [
37+
{
38+
id: TERM_ID.PRIVACY_POLICY,
39+
title: PRIVACY_POLICY_TITLE,
40+
required: true,
41+
},
42+
{
43+
id: TERM_ID.TERMS_OF_SERVICE,
44+
title: TERMS_OF_SERVICE_TITLE,
45+
required: true,
46+
},
47+
];
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { useParams } from 'react-router-dom';
2+
3+
import { Header } from 'components/Header';
4+
import { BackButton } from 'components/Header/BackButton';
5+
6+
import { TERM_BY_ID, type TermId } from 'constants/terms';
7+
8+
const TermsDetail = () => {
9+
const { termId } = useParams();
10+
11+
const parsedTermId = Number(termId);
12+
const term = TERM_BY_ID[parsedTermId as TermId];
13+
14+
if (!term) return null;
15+
16+
return (
17+
<>
18+
<Header title={term.title} leftBtn={<BackButton />} />
19+
20+
<section className="h-full overflow-y-auto px-mobile pb-safe-bottom pt-4">
21+
<p className="whitespace-pre-wrap text-body1">{term.content}</p>
22+
</section>
23+
</>
24+
);
25+
};
26+
27+
export default TermsDetail;

src/pages/SignUp/TermsStep/index.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,18 @@ import { Header } from 'components/Header';
66
import { BackButton } from 'components/Header/BackButton';
77
import { IconArrowRight } from 'components/icons';
88

9+
import { SIGNUP_TERMS } from 'constants/terms';
10+
911
import { Description } from '../shared/Description';
1012
import { Title } from '../shared/Title';
1113

12-
type TermItem = {
13-
id: number;
14-
title: string;
15-
required: boolean;
16-
};
17-
1814
type TermsStepProps = {
1915
agreedTermIds: number[];
2016
onChangeAgreedTermIds: (ids: number[]) => void;
2117
onPrev: () => void;
2218
onNext: () => void;
2319
};
2420

25-
const TERMS: TermItem[] = [
26-
{ id: 1, title: '개인정보처리방침', required: true },
27-
{ id: 2, title: '이용약관', required: true },
28-
];
29-
3021
const MSG_SIGNUP_HEADER_TITLE = '회원가입';
3122
const MSG_SIGNUP_TERMS_TITLE = '빼곡에 가입하시려면\n이용약관에 동의해주세요!';
3223
const MSG_SIGNUP_TERMS_DESCRIPTION = '회원가입을 마치기 전에 빼곡의 이용약관을 확인해주세요';
@@ -38,16 +29,16 @@ export const TermsStep = (props: TermsStepProps) => {
3829
const { agreedTermIds, onChangeAgreedTermIds, onPrev, onNext } = props;
3930
const navigate = useNavigate();
4031

41-
const requiredTermIds = TERMS.filter((term) => term.required).map((term) => term.id);
32+
const requiredTermIds = SIGNUP_TERMS.filter((term) => term.required).map((term) => term.id);
4233
const isCompleteEnabled = requiredTermIds.every((id) => agreedTermIds.includes(id));
4334

4435
const handleToggleAll = () => {
45-
if (agreedTermIds.length === TERMS.length) {
36+
if (agreedTermIds.length === SIGNUP_TERMS.length) {
4637
onChangeAgreedTermIds([]);
4738
return;
4839
}
4940

50-
onChangeAgreedTermIds(TERMS.map((term) => term.id));
41+
onChangeAgreedTermIds(SIGNUP_TERMS.map((term) => term.id));
5142
};
5243

5344
const handleClickTermDetail = (termId: number) => {
@@ -84,10 +75,10 @@ export const TermsStep = (props: TermsStepProps) => {
8475
</Button>
8576

8677
<ul className="mb-3 ml-1.5 mt-4">
87-
{TERMS.map((term, index) => {
78+
{SIGNUP_TERMS.map((term, index) => {
8879
const isChecked = agreedTermIds.includes(term.id);
8980
const detailButtonClass = 'flex items-center gap-1 text-title3 text-neutral-100';
90-
const itemBorderClass = index === TERMS.length - 1 ? '' : 'border-b border-neutral-10';
81+
const itemBorderClass = index === SIGNUP_TERMS.length - 1 ? '' : 'border-b border-neutral-10';
9182

9283
return (
9384
<li key={term.id} className={`flex h-12 items-center justify-between ${itemBorderClass}`}>

0 commit comments

Comments
 (0)