From 3578615cbcca124894f957b4e98eafd9a3a26338 Mon Sep 17 00:00:00 2001 From: lareii Date: Tue, 3 Sep 2024 18:08:12 +0300 Subject: [PATCH] refactor(client): some rendering improvements --- client/app/app/posts/[id]/page.jsx | 4 ++-- client/components/app/Comment/index.jsx | 19 ++++------------ client/components/app/Post/index.jsx | 29 +++++-------------------- 3 files changed, 11 insertions(+), 41 deletions(-) diff --git a/client/app/app/posts/[id]/page.jsx b/client/app/app/posts/[id]/page.jsx index a9918fe..45df90c 100644 --- a/client/app/app/posts/[id]/page.jsx +++ b/client/app/app/posts/[id]/page.jsx @@ -16,7 +16,7 @@ export default function Page({ params }) { } useEffect(() => { - const fetchUser = async () => { + const fetchPost = async () => { const response = await getPost(params); if (!response) { toast({ @@ -29,7 +29,7 @@ export default function Page({ params }) { setPost(response.data.post); }; - fetchUser(); + fetchPost(); }, []); return ( diff --git a/client/components/app/Comment/index.jsx b/client/components/app/Comment/index.jsx index 1425c2f..cb93fd4 100644 --- a/client/components/app/Comment/index.jsx +++ b/client/components/app/Comment/index.jsx @@ -1,7 +1,5 @@ import { useState } from 'react'; import UserHoverCard from '@/components/app/HoverCard'; -import { Skeleton } from '@/components/ui/skeleton'; -import { Button } from '@/components/ui/button'; import Dropdown from '@/components/app/Comment/Dropdown'; import LikeButton from '@/components/app/Comment/LikeButton'; @@ -14,26 +12,17 @@ export default function Comment({ comment: initialComment, onDelete }) {
- {comment ? ( - <> - -
@{comment.author.username}
- - ) : ( - <> - - - - )} + +
@{comment.author.username}
- {comment ? comment.content : } + {comment.content}
- {comment ? : } +
); diff --git a/client/components/app/Post/index.jsx b/client/components/app/Post/index.jsx index 67aad40..e0fd683 100644 --- a/client/components/app/Post/index.jsx +++ b/client/components/app/Post/index.jsx @@ -1,6 +1,5 @@ import { useState } from 'react'; import Dropdown from '@/components/app/Post/Dropdown'; -import { Skeleton } from '@/components/ui/skeleton'; import UserHoverCard from '@/components/app/HoverCard'; import LikeButton from '@/components/app/Post/LikeButton'; import CommentButton from '@/components/app/Post/CommentButton'; @@ -14,17 +13,8 @@ export default function Post({ post: initialPost, onDelete, onNewComment }) {
- {post ? ( - <> - -
@{post.author.username}
- - ) : ( - <> - - - - )} + +
@{post.author.username}
{/*
@@ -34,20 +24,11 @@ export default function Post({ post: initialPost, onDelete, onNewComment }) {
- {post ? post.content : } + {post.content}
- {post ? ( - <> - - - - ) : ( - <> - - - - )} + +
);