From a51d397ded1c423f264a0ecc1c7a6c0d3e785a59 Mon Sep 17 00:00:00 2001 From: Hollgy Date: Sun, 24 Mar 2024 22:31:28 +0100 Subject: [PATCH] Refactor, added navigation to comment button --- .../src/Components/Buttons/CommentsButton.tsx | 17 +++++++++++++++-- client-solid/src/Components/PostSegment.tsx | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/client-solid/src/Components/Buttons/CommentsButton.tsx b/client-solid/src/Components/Buttons/CommentsButton.tsx index a9bec4c..5c7dfef 100644 --- a/client-solid/src/Components/Buttons/CommentsButton.tsx +++ b/client-solid/src/Components/Buttons/CommentsButton.tsx @@ -1,10 +1,18 @@ -import { JSXElement, createSignal, onMount } from "solid-js"; +import { useNavigate } from "@solidjs/router"; +import { JSXElement, createEffect, createSignal, onMount } from "solid-js"; import { CommentsIcon } from "../../Util/Icons"; import { getCommentCount } from "../../Util/api"; export default function CommentsButton(props: { postId: string }): JSXElement { const [commentCount, setCommentCount] = createSignal(0); + const [postId, setPostId] = createSignal(""); + + const nav = useNavigate(); + + createEffect(() => { + setPostId(props.postId); + }); const handleComments = async (): Promise => { try { @@ -20,7 +28,12 @@ export default function CommentsButton(props: { postId: string }): JSXElement { return (
- +

diff --git a/client-solid/src/Components/PostSegment.tsx b/client-solid/src/Components/PostSegment.tsx index cf5c6c2..5578f0f 100644 --- a/client-solid/src/Components/PostSegment.tsx +++ b/client-solid/src/Components/PostSegment.tsx @@ -16,7 +16,7 @@ export function PostSegment(props: { post: Post }): JSXElement {

-

{dateOfCreation}

+

{dateOfCreation}