diff --git a/client-solid/package.json b/client-solid/package.json index 256b3c9..3e57bf6 100644 --- a/client-solid/package.json +++ b/client-solid/package.json @@ -36,4 +36,4 @@ "vite-plugin-qrcode": "^0.2.3", "vite-plugin-solid": "^2.8.0" } -} \ No newline at end of file +} diff --git a/client-solid/src/Components/Comment.tsx b/client-solid/src/Components/Comment.tsx index 802d2ef..f108b08 100644 --- a/client-solid/src/Components/Comment.tsx +++ b/client-solid/src/Components/Comment.tsx @@ -1,8 +1,12 @@ import { JSXElement } from "solid-js"; -import { ReplyIcon } from "../Util/Icons"; import { EngagementIcon } from "../Util/Icons"; import { PublicComment } from "../Util/api"; +import { NewCommentInputArea } from "./NewComment"; + +interface CommentProps { + comment: PublicComment; +} /** * Comment is a component that displays a single comment. @@ -10,9 +14,9 @@ import { PublicComment } from "../Util/api"; * @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 { +export function Comment({ comment }: CommentProps): JSXElement { return ( -
+
{comment.created_at}
@@ -23,10 +27,27 @@ export function Comment({ comment }: { comment: PublicComment }): JSXElement { {/* Placeholder icon, tbd */}
-
- -
+
+ +
+ ); } diff --git a/client-solid/src/Components/CommentSection.tsx b/client-solid/src/Components/CommentSection.tsx index f84c218..f9f9fe4 100644 --- a/client-solid/src/Components/CommentSection.tsx +++ b/client-solid/src/Components/CommentSection.tsx @@ -10,9 +10,7 @@ import { Comment } from "./Comment"; * @returns {JSXElement} A JSXElement that contains a collection of comments. */ export function CommentSection({ postId }: { postId: string }): JSXElement { - const [comments] = createResource(postId, () => - getComments(postId, 10, 0) - ); + const [comments] = createResource(postId, () => getComments(postId, 10, 0)); return ( {(comment) => } diff --git a/client-solid/src/Components/NewComment.tsx b/client-solid/src/Components/NewComment.tsx index 774c4ee..61bc164 100644 --- a/client-solid/src/Components/NewComment.tsx +++ b/client-solid/src/Components/NewComment.tsx @@ -4,6 +4,11 @@ import { JSXElement, Show, createSignal, useContext } from "solid-js"; import { LoginContext } from "../Context/GlobalState"; import { NewComment, createComment } from "../Util/api"; +interface NewCommentInputAreaProps { + parentPostId: number; + parentCommentId: number | null; +} + /** NewCommentInputArea is a component that allows users to submit a comment on a **post or comment**. * @param {Object} props The properties for the NewCommentInputArea component. * @param {number} props.parentPostId The id of the post that the comment is a reply to. @@ -11,9 +16,8 @@ import { NewComment, createComment } from "../Util/api"; */ export function NewCommentInputArea({ parentPostId, -}: { - parentPostId: number; -}): JSXElement { + parentCommentId, +}: NewCommentInputAreaProps): JSXElement { const [content, setContent] = createSignal(""); const [waiting, setWaiting] = createSignal(false); @@ -29,6 +33,7 @@ export function NewCommentInputArea({ content: content(), user_token: login_ctx.token(), parent_post_id: parentPostId, + parent_comment_id: parentCommentId, } as NewComment); if (response) { diff --git a/client-solid/src/Components/SinglePost.tsx b/client-solid/src/Components/SinglePost.tsx index 2dfd919..7aace84 100644 --- a/client-solid/src/Components/SinglePost.tsx +++ b/client-solid/src/Components/SinglePost.tsx @@ -1,11 +1,18 @@ import { useParams } from "@solidjs/router"; -import { JSXElement, Show, Suspense, createResource, useContext } from "solid-js"; +import { + JSXElement, + Show, + Suspense, + createResource, + useContext, +} from "solid-js"; + import { LoginContext } from "../Context/GlobalState"; import { loadSpinner } from "../Util/Icons"; import { getPost } from "../Util/api"; import { CommentSection } from "./CommentSection"; -import { PostSegment } from "./Posts"; import { NewCommentInputArea } from "./NewComment"; +import { PostSegment } from "./Posts"; export function SinglePost(): JSXElement { const params = useParams(); @@ -17,7 +24,7 @@ export function SinglePost(): JSXElement { - + diff --git a/client-solid/src/Containers/PageContainer.tsx b/client-solid/src/Containers/PageContainer.tsx index c6356da..eb639ca 100644 --- a/client-solid/src/Containers/PageContainer.tsx +++ b/client-solid/src/Containers/PageContainer.tsx @@ -3,8 +3,6 @@ import { JSXElement } from "solid-js"; // MainContainer is the main container for the page. export function PageContainer(props: { children: JSXElement }): JSXElement { return ( -
- {props.children} -
+
{props.children}
); } diff --git a/client-solid/src/Util/api.ts b/client-solid/src/Util/api.ts index a800df4..4209cc8 100644 --- a/client-solid/src/Util/api.ts +++ b/client-solid/src/Util/api.ts @@ -20,6 +20,7 @@ export interface NewComment { content: string; user_token: string; parent_post_id: number; + parent_comment_id?: number; } export interface Comment extends NewComment {