Skip to content

Commit

Permalink
!!fix suspense ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
  • Loading branch information
03hoho03 committed Apr 8, 2024
1 parent 5e715fd commit ea3ad8b
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 128 deletions.
99 changes: 51 additions & 48 deletions app/(route)/main/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Title from '../../_common/text/title'
import Search from '../../_components/search'
import { Root, Tool } from '../../_constants/toolcard'
import S from './page.module.css'
import { Suspense } from 'react'

//TODO: ์ฃผ์„์ฒ˜๋ฆฌ ์‚ฌํ•ญ๋“ค์— ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
function Main() {
Expand All @@ -27,58 +28,60 @@ function Main() {
const resData = data?.data.data.tool

return (
<main className={S.wrapper}>
<Nav />
<div className={S.inWrapper}>
<Link href="/search">
<Search />
</Link>
<div className={S.marginWrapper}>
<Title title="์ธ๊ธฐ ๋งŽ์€ ํˆด" />
</div>
<div className={S.toolCardWrapper}>
<Swiper
spaceBetween={20}
slidesPerView={'auto'}
onSlideChange={() => console.log('slide change')}
onSwiper={(swiper) => console.log(swiper)}
>
{resData?.map((data: Tool, index: number) => {
<Suspense fallback={<div>...loading</div>}>
<main className={S.wrapper}>
<Nav />
<div className={S.inWrapper}>
<Link href="/search">
<Search />
</Link>
<div className={S.marginWrapper}>
<Title title="์ธ๊ธฐ ๋งŽ์€ ํˆด" />
</div>
<div className={S.toolCardWrapper}>
<Swiper
spaceBetween={20}
slidesPerView={'auto'}
onSlideChange={() => console.log('slide change')}
onSwiper={(swiper) => console.log(swiper)}
>
{resData?.map((data: Tool, index: number) => {
return (
<SwiperSlide style={{ width: '390px' }} key={index}>
<ToolCard
title={data?.title || ''}
subTitle={data?.subTitle || ''}
description={data?.description || ''}
toolImg={data?.toolImg || ''}
toolId={index}
company={data?.company}
/>
</SwiperSlide>
)
})}
</Swiper>
</div>
<div className={S.rowWrapper}>
<Title title="๊ฒ€์ฆ ํˆด ๋ฆฌ์ŠคํŠธ" />
<Link href="/list">์ž์„ธํžˆ ๋ณด๊ธฐ</Link>
</div>
<div className={S.keyWordCardWrapper}>
{resData?.map((data: Tool, index) => {
return (
<SwiperSlide style={{ width: '390px' }} key={index}>
<ToolCard
title={data?.title || ''}
subTitle={data?.subTitle || ''}
description={data?.description || ''}
toolImg={data?.toolImg || ''}
toolId={index}
company={data?.company}
/>
</SwiperSlide>
<KeyWordTool
title={data?.title || ''}
subTitle={data?.subTitle || ''}
toolImg={data?.toolImg || ''}
key={index}
toolId={index}
keyword={data.keyword}
/>
)
})}
</Swiper>
</div>
<div className={S.rowWrapper}>
<Title title="๊ฒ€์ฆ ํˆด ๋ฆฌ์ŠคํŠธ" />
<Link href="/list">์ž์„ธํžˆ ๋ณด๊ธฐ</Link>
</div>
<div className={S.keyWordCardWrapper}>
{resData?.map((data: Tool, index) => {
return (
<KeyWordTool
title={data?.title || ''}
subTitle={data?.subTitle || ''}
toolImg={data?.toolImg || ''}
key={index}
toolId={index}
keyword={data.keyword}
/>
)
})}
</div>
</div>
</div>
</main>
</main>
</Suspense>
)
}

Expand Down
5 changes: 3 additions & 2 deletions app/(route)/mypage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import Nav from '@/app/_common/nav'
import Title from '@/app/_common/text/title'
import IdeaCard from './_components/ideaCard'
import S from './mypage.module.css'
import { Suspense } from 'react'

//TODO: ์‚ฌ์šฉ์ž ๋ช…, ์•„์ด๋””์–ด ๊ฒ€์ฆ ์ˆ˜๊ฐ€ ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค.
//TODO: ์™„๋ฃŒ๋œ ์•„์ด๋””์–ด, ์ž…๋ ฅ ์ „ ์•„์ด๋””์–ด๋ฅผ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค.(get)
function Mypage() {
return (
<>
<Suspense fallback={<div>๋กœ๋”ฉ์ค‘...</div>}>
<div className={S.wrapper}>
<Nav />
<Title title="์•„์ด๋””์–ด" />
Expand All @@ -24,7 +25,7 @@ function Mypage() {
<IdeaCard />
</div>
</div>
</>
</Suspense>
)
}

Expand Down
157 changes: 79 additions & 78 deletions app/(route)/toolDetail/[toolId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import Modal from '@/app/_common/modal'
import Nav from '@/app/_common/nav'
import Title from '@/app/_common/text/title'
import { useState } from 'react'
import { Suspense, useState } from 'react'
import S from './toolDetail.module.css'
import Link from 'next/link'
import { useParams } from 'next/navigation'
import { useQuery } from '@tanstack/react-query'
import axios, { AxiosResponse } from 'axios'
Expand All @@ -30,91 +29,93 @@ function ToolDetail() {
const resData = data?.data.data.tool[Number(toolId)]

return (
<div className={S.wrapper}>
<Nav />
<div className={S.introWrapper}>
<div className={S.imgWrapper}>
<Image
src={resData?.toolImg || ''}
alt="์•„์ด๋””์–ด ํˆด ์ด๋ฏธ์ง€"
width={80}
height={80}
/>
<Suspense fallback={<div>๋กœ๋”ฉ์ค‘...</div>}>
<div className={S.wrapper}>
<Nav />
<div className={S.introWrapper}>
<div className={S.imgWrapper}>
<Image
src={resData?.toolImg || ''}
alt="์•„์ด๋””์–ด ํˆด ์ด๋ฏธ์ง€"
width={80}
height={80}
/>
</div>
<Title title={resData?.title || ''} />
<p> {resData?.createdBy}</p>
</div>
<Title title={resData?.title || ''} />
<p> {resData?.createdBy}</p>
</div>

<div className={S.contentWrapper}>
<div className={S.btnWrapper}>
<button
className={`${S.btn} ${!clickBtn ? S.clickBtn : ''}`}
onClick={() => setClickBtn((prevState) => !prevState)}
>
Description
</button>
<button
className={`${S.btn} ${clickBtn ? S.clickBtn : ''}`}
onClick={() => setClickBtn((prevState) => !prevState)}
>
Company
</button>
</div>
<div className={S.contentWrapper}>
<div className={S.btnWrapper}>
<button
className={`${S.btn} ${!clickBtn ? S.clickBtn : ''}`}
onClick={() => setClickBtn((prevState) => !prevState)}
>
Description
</button>
<button
className={`${S.btn} ${clickBtn ? S.clickBtn : ''}`}
onClick={() => setClickBtn((prevState) => !prevState)}
>
Company
</button>
</div>

{!clickBtn ? (
<>
{!clickBtn ? (
<>
<div className={S.marginWrapper}>
<Title title="๊ฐœ์š”" />
<p>{resData?.content}</p>
</div>
<div className={S.marginWrapper}>
<Title title="๊ฒ€์ฆ ๋ฐฉ์‹" />
<ul>
{resData?.verificationMethod.map((method, index) => {
return (
<li className={S.li} key={index}>
<div className={S.circle}></div>
<div className={S.method}>{method}</div>
</li>
)
})}
</ul>
</div>
</>
) : (
<div className={S.marginWrapper}>
<Title title="๊ฐœ์š”" />
<p>{resData?.content}</p>
</div>
<div className={S.marginWrapper}>
<Title title="๊ฒ€์ฆ ๋ฐฉ์‹" />
<ul>
{resData?.verificationMethod.map((method, index) => {
<Title title="์‹ค์ œ ์‚ฌ๋ก€" />

<div className={S.columnWrapper}>
{resData?.company.map((company, index) => {
return (
<li className={S.li} key={index}>
<div className={S.circle}></div>
<div className={S.method}>{method}</div>
</li>
<div className={S.examplewrap} key={index}>
<div className={S.img}>
<Image
src={company || ''}
alt="์•„์ด๋””์–ด ํˆด ์ด๋ฏธ์ง€"
width={120}
height={40}
/>
</div>
<div className={S.examplecontent}>
{resData.exampleContent[index]}
</div>
</div>
)
})}
</ul>
</div>
</div>
</>
) : (
<div className={S.marginWrapper}>
<Title title="์‹ค์ œ ์‚ฌ๋ก€" />

<div className={S.columnWrapper}>
{resData?.company.map((company, index) => {
return (
<div className={S.examplewrap} key={index}>
<div className={S.img}>
<Image
src={company || ''}
alt="์•„์ด๋””์–ด ํˆด ์ด๋ฏธ์ง€"
width={120}
height={40}
/>
</div>
<div className={S.examplecontent}>
{resData.exampleContent[index]}
</div>
</div>
)
})}
</div>
</div>
)}
)}
</div>
<Modal
open="๊ฒ€์ฆํ•˜๊ธฐ"
title="์•„์ด๋””์–ด ๋ถˆํŒจ์˜ ๋ฒ•์น™"
subTitle="์„ ํƒํ•œ ํ•ด๋‹น ์•„์ด๋””์–ด ํˆด๋กœ ๊ฒ€์‚ฌ๋ฅผ ์ง„ํ–‰ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? :)"
buttonTitle="ํ•ด๋‹น ํˆด๋กœ ๊ฒ€์ฆํ•˜๊ธฐ"
buttonLink="/verification/ibulsin?step=1"
></Modal>
</div>
<Modal
open="๊ฒ€์ฆํ•˜๊ธฐ"
title="์•„์ด๋””์–ด ๋ถˆํŒจ์˜ ๋ฒ•์น™"
subTitle="์„ ํƒํ•œ ํ•ด๋‹น ์•„์ด๋””์–ด ํˆด๋กœ ๊ฒ€์‚ฌ๋ฅผ ์ง„ํ–‰ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? :)"
buttonTitle="ํ•ด๋‹น ํˆด๋กœ ๊ฒ€์ฆํ•˜๊ธฐ"
buttonLink="/verification/ibulsin?step=1"
></Modal>
</div>
</Suspense>
)
}

Expand Down

0 comments on commit ea3ad8b

Please sign in to comment.