87 lines
2.9 KiB
TypeScript
87 lines
2.9 KiB
TypeScript
import { cx } from '../../lib/utils'
|
|
import { useSheet } from '../sheetContext'
|
|
import { EFFECTIVE_DATE, type LegalBlock, type LegalLink } from './common'
|
|
import { PRIVACY } from './privacy'
|
|
import { TERMS } from './terms'
|
|
|
|
const DOCS = { privacy: PRIVACY, terms: TERMS } as const
|
|
export type LegalKind = keyof typeof DOCS
|
|
|
|
function Item({ it }: { it: string | LegalLink }) {
|
|
if (typeof it === 'string') return <>{it}</>
|
|
return (
|
|
<>
|
|
<a href={it.href} target="_blank" rel="noopener noreferrer" className="font-bold text-(--rain) underline underline-offset-2">
|
|
{it.text}
|
|
</a>
|
|
{it.note && ` · ${it.note}`}
|
|
</>
|
|
)
|
|
}
|
|
|
|
function Block({ b }: { b: LegalBlock }) {
|
|
if (typeof b === 'string') return <p className="m-0">{b}</p>
|
|
return (
|
|
<ul className="m-0 flex list-disc flex-col gap-1 pl-5">
|
|
{b.items.map((it, i) => (
|
|
<li key={i} className="break-words">
|
|
<Item it={it} />
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)
|
|
}
|
|
|
|
/** 개인정보처리방침·이용약관 본문. 긴 글은 시트 안에서 스크롤된다 */
|
|
export function LegalSheet({ kind }: { kind: LegalKind }) {
|
|
const doc = DOCS[kind]
|
|
return (
|
|
<div className="flex-1 overflow-auto overscroll-contain px-4 pt-3.5 pb-[18px] text-[13.5px] leading-relaxed text-(--ink2)">
|
|
<p className="m-0 text-xs font-bold text-(--ink3)">시행일 {EFFECTIVE_DATE}</p>
|
|
<p className="m-0 mt-2">{doc.intro}</p>
|
|
{doc.sections.map((s) => (
|
|
<section key={s.title} className="mt-4 flex flex-col gap-1.5">
|
|
<h4 className="m-0 text-sm font-extrabold text-(--ink)">{s.title}</h4>
|
|
{s.blocks.map((b, i) => (
|
|
<Block key={i} b={b} />
|
|
))}
|
|
</section>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const linkCls = 'cursor-pointer font-extrabold text-(--ink2) underline underline-offset-2'
|
|
|
|
/** 가입 안내 문구: 각 단어를 누르면 해당 시트가 열린다 */
|
|
export function LegalConsent({ className }: { className?: string }) {
|
|
const { open } = useSheet()
|
|
return (
|
|
<p className={cx('m-0 text-center text-xs font-semibold text-(--ink3)', className)}>
|
|
가입하면{' '}
|
|
<button type="button" onClick={() => open({ type: 'terms' })} className={linkCls}>
|
|
이용약관
|
|
</button>
|
|
과{' '}
|
|
<button type="button" onClick={() => open({ type: 'privacy' })} className={linkCls}>
|
|
개인정보처리방침
|
|
</button>
|
|
에 동의하게 됩니다
|
|
</p>
|
|
)
|
|
}
|
|
|
|
export function LegalLinks({ className }: { className?: string }) {
|
|
const { open } = useSheet()
|
|
return (
|
|
<p className={cx('m-0 flex justify-center gap-3 text-xs', className)}>
|
|
<button type="button" onClick={() => open({ type: 'terms' })} className={linkCls}>
|
|
이용약관
|
|
</button>
|
|
<button type="button" onClick={() => open({ type: 'privacy' })} className={linkCls}>
|
|
개인정보처리방침
|
|
</button>
|
|
</p>
|
|
)
|
|
}
|