diff --git a/src/pageLayout/MypageLayout/MyContent.tsx b/src/pageLayout/MypageLayout/MyContent.tsx index d97e9933..81c91dda 100644 --- a/src/pageLayout/MypageLayout/MyContent.tsx +++ b/src/pageLayout/MypageLayout/MyContent.tsx @@ -2,32 +2,14 @@ import { useEffect, useState } from 'react'; import useGetEpigrams from '@/hooks/useGetEpigrams'; import MyEpigrams from '@/user/ui-content/MyEpigrams'; import Image from 'next/image'; -import { Button } from '@/components/ui/button'; import { useToast } from '@/components/ui/use-toast'; -import NONE_EPI from '../../../public/none-epi.svg'; +import { EpigramsResponse } from '@/types/epigram.types'; import spinner from '../../../public/spinner.svg'; interface MyContentProps { userId: number; } -interface Epigram { - writerId: number; - id: number; - likeCount: number; - tags: { id: number; name: string }[]; - referenceUrl: string; - referenceTitle: string; - author: string; - content: string; -} - -interface EpigramsResponse { - totalCount: number; - nextCursor: number | null; - list: Epigram[]; -} - export default function MyContent({ userId }: MyContentProps) { const limit = 3; const [cursor, setCursor] = useState(0); @@ -53,7 +35,7 @@ export default function MyContent({ userId }: MyContentProps) { } }, [data]); - const handleMoreLoad = () => { + const handleMoreEpigramLoad = () => { if (epigrams.nextCursor !== null) { setCursor(epigrams.nextCursor); setIsLoadingMore(true); @@ -75,7 +57,7 @@ export default function MyContent({ userId }: MyContentProps) {
- {epigrams.totalCount > 0 ? ( - <> - {epigrams.list.map((epi) => { - const epigram = { - epigramId: epi.id, - content: epi.content, - author: epi.author, - tags: epi.tags, - }; - return ; - })} - {epigrams.totalCount > epigrams.list.length && ( -
- -
- )} - - ) : ( -
- 돋보기아이콘 -
-
-

아직 작성한 에피그램이 없어요!

-

에피그램을 작성하고 감정을 공유해보세요.

-
- -
-
- )} + {isLoadingMore && (
로딩중 diff --git a/src/types/epigram.types.ts b/src/types/epigram.types.ts index 226ee9ee..0c2d0303 100644 --- a/src/types/epigram.types.ts +++ b/src/types/epigram.types.ts @@ -22,3 +22,20 @@ export interface PatchCommentRequest { isPrivate: boolean; content: string; } + +export interface Epigram { + writerId: number; + id: number; + likeCount: number; + tags: { id: number; name: string }[]; + referenceUrl: string; + referenceTitle: string; + author: string; + content: string; +} + +export interface EpigramsResponse { + totalCount: number; + nextCursor: number | null; + list: Epigram[]; +} diff --git a/src/user/ui-content/MyEpigrams.tsx b/src/user/ui-content/MyEpigrams.tsx index 0fb1dbf4..7ae267a4 100644 --- a/src/user/ui-content/MyEpigrams.tsx +++ b/src/user/ui-content/MyEpigrams.tsx @@ -1,7 +1,9 @@ import React from 'react'; +import Image from 'next/image'; +import { Button } from '@/components/ui/button'; +import { Epigram } from '@/types/epigram.types'; +import NONE_EPI from '../../../public/none-epi.svg'; -// figma 상으로는 sm ~ 3xl 사이즈로 구현되어 있는데, tailwind 환경을 반영해 -// xs ~ 2xl 으로 정의했습니다. const sizeStyles = { xs: 'w-[286px] max-h-[132px]', sm: 'sm:w-[312px] sm:max-h-[152px]', @@ -18,50 +20,63 @@ const textSizeStyles = { xl: 'xl:text-2xl', }; -interface Tag { - name: string; - id: number; -} - interface MyEpigramProps { - epigram: { - epigramId: number; - content: string; - author: string; - tags: Tag[]; - }; + epigrams: Epigram[]; + totalCount: number; + onMoreEpigramLoad: () => void; } -function MyEpigrams({ epigram }: MyEpigramProps) { - return ( -
-
- {/* eslint-disable-next-line */} -
{/* 줄무늬를 만들려면 비어있는 div가 필요합니다. */} -
-
-
- {epigram.content} -
-
- - {epigram.author} - +function MyEpigrams({ epigrams, totalCount, onMoreEpigramLoad }: MyEpigramProps) { + return totalCount > 0 ? ( +
+ {epigrams.map((epigram) => ( +
+
+
+
+
+
+ {epigram.content} +
+
+ - {epigram.author} - +
+
-
-
-
- {epigram.tags.map((tag) => ( -
- #{tag.name} +
+ {epigram.tags.map((tag) => ( +
+ #{tag.name} +
+ ))}
- ))} +
+ ))} + {totalCount > epigrams.length && ( +
+ +
+ )} +
+ ) : ( +
+ 돋보기아이콘 +
+
+

아직 작성한 에피그램이 없어요!

+

에피그램을 작성하고 감정을 공유해보세요.

+
+
);