diff --git a/src/features/posts/components/NoPost/NoPost.tsx b/src/features/posts/components/NoPost/NoPost.tsx new file mode 100644 index 00000000..a58382ec --- /dev/null +++ b/src/features/posts/components/NoPost/NoPost.tsx @@ -0,0 +1,35 @@ +import { useNavigate } from 'react-router-dom'; +import { POST_TYPE } from '@/common/constants/post-type'; +import { ReactComponent as NoPostIcon } from './no-post-icon.svg'; + +interface NoPostText { + type: POST_TYPE; +} + +export function NoPost({ type }: NoPostText) { + const navigate = useNavigate(); + + const text = + type === POST_TYPE.MY + ? '아직 작성한 게시물이 없어요.' + : '투표하거나 댓글 남긴 게시글이 없어요.'; + + return ( +
+ + {text} + {type === POST_TYPE.MY && ( + navigate('/write')} + > + 글 작성 시작 + + )} +
+ ); +} diff --git a/src/features/posts/components/NoPost/index.ts b/src/features/posts/components/NoPost/index.ts new file mode 100644 index 00000000..a84ba2ea --- /dev/null +++ b/src/features/posts/components/NoPost/index.ts @@ -0,0 +1 @@ +export { NoPost } from './NoPost'; diff --git a/src/features/posts/components/NoPost/no-post-icon.svg b/src/features/posts/components/NoPost/no-post-icon.svg new file mode 100644 index 00000000..d5270f72 --- /dev/null +++ b/src/features/posts/components/NoPost/no-post-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/features/posts/components/PostCardList/PostCardList.tsx b/src/features/posts/components/PostCardList/PostCardList.tsx index d585c7f6..a06b5208 100644 --- a/src/features/posts/components/PostCardList/PostCardList.tsx +++ b/src/features/posts/components/PostCardList/PostCardList.tsx @@ -1,4 +1,5 @@ import { POST_TYPE } from '@/common/constants/post-type'; +import { NoPost } from '@/features/posts/components/NoPost'; import { PostCard } from '@/features/posts/components/PostCard'; import { useGetPosts } from '@/features/posts/queries'; import { useUser } from '@/features/user/queries/useUser'; @@ -14,6 +15,10 @@ export function PostCardList({ type }: PostCardListProps) { type, }); + if (type !== POST_TYPE.ALL && posts?.length === 0) { + return ; + } + return (