diff --git a/client-solid/src/Components/Comment.tsx b/client-solid/src/Components/Comment.tsx index c3ce3c0..0ceb98f 100644 --- a/client-solid/src/Components/Comment.tsx +++ b/client-solid/src/Components/Comment.tsx @@ -1,47 +1,19 @@ -import { useNavigate } from "@solidjs/router"; -import { For, JSXElement, Show, createSignal } from "solid-js"; - -import { CheckMark, loadSpinner } from "../Util/Icons"; -import { PublicComment, getComments } from "../Util/api"; - -//exported into primary as a Route -export function Comment({ postId }: { postId: string }): JSXElement { - const [comments, setComments] = createSignal([] as PublicComment[]); - const [loading, setLoading] = createSignal(true); - - getComments(postId, 10, 0).then((comment) => { - setComments(comment); - setLoading(false); - }); +import { JSXElement, } from "solid-js"; +import { PublicComment } from "../Util/api"; +/** + * Comment is a component that displays a single comment. + * @param {Object} props The properties for the Comment component. + * @param {string} props.postId The id of the post that the comment is a reply to. + * @returns {JSXElement} A JSXElement of a comment + */ +export function Comment({ comment }: { comment: PublicComment }): JSXElement { return ( - - - {(comment): JSXElement => } - - - ); -} - -export function CommentSegment(props: { comment: PublicComment }): JSXElement { - const nav = useNavigate(); - return ( -
-
-

- {props.comment?.content} -

-
- -
+
+
+
{comment.created_at}
+
{comment.content}
); } diff --git a/client-solid/src/Components/CommentSection.tsx b/client-solid/src/Components/CommentSection.tsx index 998ea28..f84c218 100644 --- a/client-solid/src/Components/CommentSection.tsx +++ b/client-solid/src/Components/CommentSection.tsx @@ -1,18 +1,20 @@ -import { - For, - JSXElement, - createResource, -} from "solid-js"; +import { For, JSXElement, createResource } from "solid-js"; import { getComments } from "../Util/api"; -import { CommentSegment } from "./Comment"; +import { Comment } from "./Comment"; +/** + * CommentSection is a component that displays a collection of comments. + * @param {Object} props The properties for the CommentSection component. + * @param {string} props.postId The id of the post that the comments are a reply to. + * @returns {JSXElement} A JSXElement that contains a collection of comments. + */ export function CommentSection({ postId }: { postId: string }): JSXElement { - const [comments] = createResource(postId, () => getComments(postId, 0, 10)); + const [comments] = createResource(postId, () => + getComments(postId, 10, 0) + ); return ( - - {(comment) => } - + {(comment) => } ); } diff --git a/client-solid/src/Components/NewComment.tsx b/client-solid/src/Components/NewComment.tsx index ccfea2c..55c3922 100644 --- a/client-solid/src/Components/NewComment.tsx +++ b/client-solid/src/Components/NewComment.tsx @@ -35,7 +35,7 @@ export function NewCommentInputArea({ response.then(() => { setWaiting(false); setContent(""); - nav("/"); + nav("/post/" + parentPostId); }); } }; diff --git a/client-solid/src/Components/SinglePost.tsx b/client-solid/src/Components/SinglePost.tsx index 258bdb2..65c41dd 100644 --- a/client-solid/src/Components/SinglePost.tsx +++ b/client-solid/src/Components/SinglePost.tsx @@ -16,7 +16,7 @@ export function SinglePost(): JSXElement { - + );