Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wildcatco committed Aug 21, 2023
2 parents 7399095 + 8cace74 commit 9a5c1f2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function CommentHeader({
age={age}
isAdmin={email === ADMIN_EMAIL}
/>
{choice && (
{choice && !isWriter && (
<div className="flex items-center space-x-[6px]">
<div className="h-[0.3rem] w-[0.3rem] rounded-full bg-[#cccfd4]"></div>
<span className="accent-text-subTitle-700 font-system-body1">
Expand Down
35 changes: 35 additions & 0 deletions src/features/posts/components/NoPost/NoPost.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div
className={
'absolute left-1/2 top-[45%] flex -translate-x-1/2 flex-col items-center'
}
>
<NoPostIcon className={'h-[7.512rem] w-[7.496rem]'} />
<span className="mt-[1.688rem] font-system-body3">{text}</span>
{type === POST_TYPE.MY && (
<span
className="cursor-pointer text-mainSub-main-500 underline font-system-body4"
onClick={() => navigate('/write')}
>
글 작성 시작
</span>
)}
</div>
);
}
1 change: 1 addition & 0 deletions src/features/posts/components/NoPost/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { NoPost } from './NoPost';
1 change: 1 addition & 0 deletions src/features/posts/components/NoPost/no-post-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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/post-card/PostCard';
import { useGetPosts } from '@/features/posts/queries';
import { useUser } from '@/features/user/queries/useUser';
Expand All @@ -14,6 +15,10 @@ export function PostCardList({ type }: PostCardListProps) {
type,
});

if (type !== POST_TYPE.ALL && posts?.length === 0) {
return <NoPost type={type} />;
}

return (
<ul className={'flex w-full flex-col items-center space-y-[1.7rem]'}>
{posts?.map((post, index) => (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/user/UserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function UserPage() {
<PageWrapper>
<UserPageHeader />
<Divider className={'my-[1.9rem]'} />
<main className={'flex min-h-0 w-full flex-col'}>
<main className={'flex h-full min-h-0 w-full flex-col'}>
<Suspense fallback={'fuck'}>
<PostTypeTabList
selectedPostType={selectedPostType}
Expand All @@ -62,7 +62,7 @@ function UserPage() {
: participatedPostsRef,
])
}
className={'hide-scrollbar overflow-y-scroll px-[2.5rem]'}
className={'hide-scrollbar h-full overflow-y-scroll px-[2.5rem]'}
>
<Suspense fallback={<PostCardListSkeleton />}>
<PostCardList type={selectedPostType} />
Expand Down

0 comments on commit 9a5c1f2

Please sign in to comment.