22
33import { useState } from 'react' ;
44import { viewPost } from '@/lib/api' ;
5+ import type { GetPostMetadataResponse } from '@/lib/api' ;
56import { sanitizeHtml } from '@/lib/sanitize' ;
67import ReportModal from '@/components/ReportModal' ;
78
89type Step = 'auth' | 'view' ;
910
10- export default function PostUnlock ( { slug } : { slug : string } ) {
11+ interface Props {
12+ slug : string ;
13+ meta : GetPostMetadataResponse | null ;
14+ }
15+
16+ export default function PostUnlock ( { slug, meta } : Props ) {
1117 const [ step , setStep ] = useState < Step > ( 'auth' ) ;
1218 const [ password , setPassword ] = useState ( '' ) ;
1319 const [ post , setPost ] = useState < { title : string ; content : string } | null > ( null ) ;
@@ -57,6 +63,45 @@ export default function PostUnlock({ slug }: { slug: string }) {
5763 ) ;
5864 }
5965
66+ // 존재하지 않는 게시글
67+ if ( meta === null ) {
68+ return (
69+ < section className = "mx-auto max-w-md px-4 py-16" >
70+ < div className = "rounded-xl border border-border bg-surface-card p-8 shadow-md text-center" >
71+ < div className = "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-error-bg" >
72+ < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "h-6 w-6 text-error" >
73+ < circle cx = "12" cy = "12" r = "10" />
74+ < line x1 = "12" x2 = "12" y1 = "8" y2 = "12" />
75+ < line x1 = "12" x2 = "12.01" y1 = "16" y2 = "16" />
76+ </ svg >
77+ </ div >
78+ < h1 className = "text-lg font-semibold text-text-primary" > 존재하지 않는 문서</ h1 >
79+ < p className = "mt-1 text-sm text-text-secondary" > 링크가 잘못되었거나 삭제된 문서입니다.</ p >
80+ </ div >
81+ </ section >
82+ ) ;
83+ }
84+
85+ // 만료된 게시글
86+ if ( meta . isExpired ) {
87+ return (
88+ < section className = "mx-auto max-w-md px-4 py-16" >
89+ < div className = "rounded-xl border border-border bg-surface-card p-8 shadow-md text-center" >
90+ < div className = "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-error-bg" >
91+ < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "h-6 w-6 text-error" >
92+ < circle cx = "12" cy = "12" r = "10" />
93+ < polyline points = "12 6 12 12 16 14" />
94+ </ svg >
95+ </ div >
96+ < h1 className = "text-lg font-semibold text-text-primary" > 만료된 문서</ h1 >
97+ < p className = "mt-1 text-sm text-text-secondary" >
98+ 열람 기간이 지나 더 이상 접근할 수 없습니다.
99+ </ p >
100+ </ div >
101+ </ section >
102+ ) ;
103+ }
104+
60105 return (
61106 < section className = "mx-auto max-w-md px-4 py-16" >
62107 < div className = "rounded-xl border border-border bg-surface-card p-8 shadow-md text-center" >
@@ -68,7 +113,7 @@ export default function PostUnlock({ slug }: { slug: string }) {
68113 </ svg >
69114 </ div >
70115
71- < h1 className = "text-lg font-semibold text-text-primary" > 보호된 문서 </ h1 >
116+ < h1 className = "text-lg font-semibold text-text-primary" > { meta . title } </ h1 >
72117 < p className = "mt-1 text-sm text-text-secondary" >
73118 이 문서는 비밀번호로 보호되어 있습니다.
74119 </ p >
0 commit comments