@@ -7,6 +7,7 @@ import Contents from '@/components/wiki.page/Contents';
77import Spinner from '@/components/Spinner' ;
88import IconFaceDizzy from '@/components/Svg/IconFaceDizzy' ;
99import ErrorMessage from '@/components/ErrorMessage' ;
10+ import MyWikiError from '@/components/MyWikiError' ;
1011
1112const getProfileData = async ( code : string ) : Promise < ProfileAnswer | null > => {
1213 try {
@@ -20,6 +21,7 @@ const getProfileData = async (code: string): Promise<ProfileAnswer | null> => {
2021export default function Wiki ( ) {
2122 const [ profile , setProfile ] = useState < ProfileAnswer | null > ( null ) ;
2223 const [ isError , setIsError ] = useState ( false ) ;
24+ const [ isMyWikiBlank , setIsMyWikiBlank ] = useState ( false ) ;
2325 const router = useRouter ( ) ;
2426 const { code } = router . query ;
2527
@@ -31,7 +33,7 @@ export default function Wiki() {
3133 if ( profileData ) {
3234 setProfile ( profileData ) ; // 프로필 상태 업데이트
3335 } else {
34- setIsError ( true ) ;
36+ setIsMyWikiBlank ( true ) ;
3537 }
3638 } catch ( error ) {
3739 setIsError ( true ) ;
@@ -42,34 +44,47 @@ export default function Wiki() {
4244 fetchProfile ( ) ;
4345 } , [ code ] ) ;
4446
45- return (
46- < >
47- { isError ? (
48- < div className = "min-h-screen" >
49- < div className = "container flex min-h-screen items-center justify-center" >
50- < div className = "inline-flex gap-8 px-4 mo:flex-col mo:gap-2" >
51- < IconFaceDizzy width = { 180 } height = { 180 } className = "mo:mx-auto" />
47+ if ( isError ) {
48+ return (
49+ < div className = "min-h-screen" >
50+ < div className = "container flex min-h-screen items-center justify-center" >
51+ < div className = "inline-flex gap-8 px-4 mo:flex-col mo:gap-2" >
52+ < IconFaceDizzy width = { 180 } height = { 180 } className = "mo:mx-auto" />
5253
53- < ErrorMessage
54- title = "데이터를 가져오는데 문제가 있어요."
55- code = "500"
56- >
57- 서버에서 전송한 데이터를 가져오는데 문제가 발생했습니다.
58- < br />
59- 다시 한 번 시도해주세요.
60- </ ErrorMessage >
61- </ div >
54+ < ErrorMessage title = "데이터를 가져오는데 문제가 있어요." code = "500" >
55+ 서버에서 전송한 데이터를 가져오는데 문제가 발생했습니다.
56+ < br />
57+ 다시 한 번 시도해주세요.
58+ </ ErrorMessage >
6259 </ div >
6360 </ div >
64- ) : profile ? (
65- < div className = "mt-[120px] flex justify-center pc:mx-[100px]" >
66- < Contents key = { profile . code } profile = { profile } />
67- </ div >
68- ) : (
69- < div className = "flex h-[calc(100vh-120px)] items-center justify-center" >
70- < Spinner size = { 10 } />
61+ </ div >
62+ ) ;
63+ }
64+
65+ if ( isMyWikiBlank ) {
66+ return (
67+ < div className = "container flex min-h-screen items-center justify-center" >
68+ < div className = "inline-flex gap-8 px-4 mo:flex-col mo:gap-2" >
69+ < MyWikiError title = "내 위키가 비어있어요" >
70+ 마이페이지에서 내 위키를 생성해주세요.
71+ </ MyWikiError >
7172 </ div >
72- ) }
73- </ >
73+ </ div >
74+ ) ;
75+ }
76+
77+ if ( profile ) {
78+ return (
79+ < div className = "mt-[120px] flex justify-center pc:mx-[100px]" >
80+ < Contents key = { profile . code } profile = { profile } />
81+ </ div >
82+ ) ;
83+ }
84+
85+ return (
86+ < div className = "flex h-[calc(100vh-120px)] items-center justify-center" >
87+ < Spinner size = { 10 } />
88+ </ div >
7489 ) ;
7590}
0 commit comments