From 7c1016b55ab165f1951a9b72d849b1a69bb61dd5 Mon Sep 17 00:00:00 2001 From: ajeeshRS Date: Fri, 23 Aug 2024 09:04:52 +0530 Subject: [PATCH] resolve issues with questions-ui --- src/app/questions/[slug]/@answers/page.tsx | 2 + src/app/questions/page.tsx | 2 +- src/components/posts/PostCard.tsx | 84 ++++++++++++---------- 3 files changed, 48 insertions(+), 40 deletions(-) diff --git a/src/app/questions/[slug]/@answers/page.tsx b/src/app/questions/[slug]/@answers/page.tsx index 516a076a4..ec821d83b 100644 --- a/src/app/questions/[slug]/@answers/page.tsx +++ b/src/app/questions/[slug]/@answers/page.tsx @@ -102,6 +102,8 @@ const SingleAnswerPage = async ({ searchParams, ); + if (answers.length === 0) return null; + return (
diff --git a/src/app/questions/page.tsx b/src/app/questions/page.tsx index 1c50097a7..3fee49b0b 100644 --- a/src/app/questions/page.tsx +++ b/src/app/questions/page.tsx @@ -216,7 +216,7 @@ export default async function Home({
-
+
{response?.data?.map((post) => ( = ({ const { theme } = useTheme(); const [markDownValue, setMarkDownValue] = useState(''); const [enableReply, setEnableReply] = useState(false); + const ref = useRef(null); + const handleMarkdownChange = (newValue?: string) => { if (typeof newValue === 'string') { setMarkDownValue(newValue); @@ -89,9 +91,19 @@ const PostCard: React.FC = ({ }); }; + const handleReplyBtn = () => { + setEnableReply((prev) => !prev); + setTimeout(() => { + ref.current?.scrollIntoView({ + behavior: 'instant', + block: 'nearest', + }); + }, 200); + }; + const internalDetails = () => { return ( -
+
{post.author.name?.substring(0, 2).toUpperCase()} @@ -105,10 +117,10 @@ const PostCard: React.FC = ({ {post.author.name}
- + {dayjs(post.createdAt).fromNow()} - + • Updated {dayjs(post.updatedAt).fromNow()}
@@ -136,6 +148,12 @@ const PostCard: React.FC = ({
+
+ {isExtendedQuestion(post) && + post.tags + .filter((v) => v !== '') + .map((v, index) => )} +
{!isAnswer && enableLink && isExtendedQuestion(post) && ( @@ -144,6 +162,26 @@ const PostCard: React.FC = ({ )} + {!isAnswer && !enableLink && isExtendedQuestion(post) && ( + + {post?.title} + + )} + {post.content && ( +
+
+ +
+ )}
@@ -159,9 +197,9 @@ const PostCard: React.FC = ({ {reply && ( @@ -193,44 +231,12 @@ const PostCard: React.FC = ({ ))}
- {isExtendedQuestion(post) && - post.tags - .filter((v) => v !== '') - .map((v, index) => )} - - {/* {!isAnswer && enableLink && isExtendedQuestion(post) && ( - - - {post?.title} - - - )} */} - {!isAnswer && !enableLink && isExtendedQuestion(post) && ( - - {post?.title} - - )} - {post.content && ( -
-
- -
- )} {enableReply && (

-
+