diff --git a/client-solid/src/Components/Buttons/CommentsButton.tsx b/client-solid/src/Components/Buttons/CommentsButton.tsx
index 700c7b0..3895d18 100644
--- a/client-solid/src/Components/Buttons/CommentsButton.tsx
+++ b/client-solid/src/Components/Buttons/CommentsButton.tsx
@@ -1,17 +1,14 @@
import { JSXElement } from "solid-js";
import { CommentsIcon } from "../../Util/Icons";
-import { Post } from "../../Util/api";
-export default function CommentsBUtton({ post }: { post: Post }): JSXElement {
+export default function CommentsButton(): JSXElement {
return (
- <>
-
-
-
-
{post.comments}
-
-
- >
+
+
+
+
+
+
);
}
diff --git a/client-solid/src/Components/Buttons/Engegament.tsx b/client-solid/src/Components/Buttons/Engegament.tsx
index d6018f8..c768418 100644
--- a/client-solid/src/Components/Buttons/Engegament.tsx
+++ b/client-solid/src/Components/Buttons/Engegament.tsx
@@ -1,20 +1,19 @@
import { JSXElement } from "solid-js";
import { EngagementIcon } from "../../Util/Icons";
-import { Post } from "../../Util/api";
-export default function EngagementButton({ post }: { post: Post }): JSXElement {
+export default function EngagementButton(): JSXElement {
return (
<>
-
-
{post.votes}
+
+
>
diff --git a/client-solid/src/Components/Buttons/RemovePostButton.tsx b/client-solid/src/Components/Buttons/RemovePostButton.tsx
index 3d53908..50595f9 100644
--- a/client-solid/src/Components/Buttons/RemovePostButton.tsx
+++ b/client-solid/src/Components/Buttons/RemovePostButton.tsx
@@ -1,9 +1,8 @@
import { JSXElement } from "solid-js";
import { RemovePostIcon } from "../../Util/Icons";
-import { Post } from "../../Util/api";
-export default function RemovePostButton({ post }: { post: Post }): JSXElement {
+export default function RemovePostButton(): JSXElement {
return (
<>
diff --git a/client-solid/src/Components/Buttons/Reply.tsx b/client-solid/src/Components/Buttons/Reply.tsx
index ead9dd7..21323b4 100644
--- a/client-solid/src/Components/Buttons/Reply.tsx
+++ b/client-solid/src/Components/Buttons/Reply.tsx
@@ -1,7 +1,7 @@
import { JSXElement, Show, useContext } from "solid-js";
import { LoginContext } from "../../Context/GlobalState";
-import { ReplyIcon, ReportIcon } from "../../Util/Icons";
+import { ReplyIcon } from "../../Util/Icons";
export default function ReplyButton(): JSXElement {
const login_ctx = useContext(LoginContext)!;
diff --git a/client-solid/src/Components/Buttons/ToPost.tsx b/client-solid/src/Components/Buttons/ToPost.tsx
index f54d776..4e354b9 100644
--- a/client-solid/src/Components/Buttons/ToPost.tsx
+++ b/client-solid/src/Components/Buttons/ToPost.tsx
@@ -1,24 +1,21 @@
import { useNavigate } from "@solidjs/router";
import { JSXElement } from "solid-js";
-
-
import { Arrow } from "../../Util/Icons";
import { Post } from "../../Util/api";
-
-export default function ToPostButton({ post }: { post: Post }): JSXElement {
- const nav = useNavigate();
+export default function ToPostButton(props: { post: Post }): JSXElement {
+ const nav = useNavigate();
return (
);
-}
\ No newline at end of file
+}
diff --git a/client-solid/src/Components/Comment.tsx b/client-solid/src/Components/Comment.tsx
index d986055..a021681 100644
--- a/client-solid/src/Components/Comment.tsx
+++ b/client-solid/src/Components/Comment.tsx
@@ -7,27 +7,23 @@ interface CommentProps {
comment: PublicComment;
}
-/**
- * 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 }: CommentProps): JSXElement {
+export function Comment(props: CommentProps): JSXElement {
return (
<>
-
+
-
{comment.content}
-
+
{props.comment.content}
+
-
-
Replies to parent comment if any
+
+
Replies to parent comment if any
-
+
+
+
>
);
}
diff --git a/client-solid/src/Components/CommentSection.tsx b/client-solid/src/Components/CommentSection.tsx
index 2baf64a..994553a 100644
--- a/client-solid/src/Components/CommentSection.tsx
+++ b/client-solid/src/Components/CommentSection.tsx
@@ -3,17 +3,13 @@ import { For, JSXElement, createResource } from "solid-js";
import { getComments } from "../Util/api";
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, 10, 0));
+export function CommentSection(props: { postId: string }): JSXElement {
+ const [comments] = createResource(props.postId, () =>
+ getComments(props.postId, 10, 0)
+ );
return (
-
+ {(comment) => }
);
diff --git a/client-solid/src/Components/LoginButton.tsx b/client-solid/src/Components/LoginButton.tsx
index 82fed43..b8bea26 100644
--- a/client-solid/src/Components/LoginButton.tsx
+++ b/client-solid/src/Components/LoginButton.tsx
@@ -1,7 +1,6 @@
import { JSXElement, Show, createSignal, useContext } from "solid-js";
import { LoginContext, ModalContext } from "../Context/GlobalState";
-import { UserCircle } from "../Util/Icons";
export function LoginButton(): JSXElement {
const modal_ctx = useContext(ModalContext)!;
@@ -35,7 +34,7 @@ export function LoginButton(): JSXElement {
{showLogoutModal() && (
Do you wish to logout?
diff --git a/client-solid/src/Components/Menu.tsx b/client-solid/src/Components/Menu.tsx
index 841de3e..3623dea 100644
--- a/client-solid/src/Components/Menu.tsx
+++ b/client-solid/src/Components/Menu.tsx
@@ -2,7 +2,7 @@ import { A } from "@solidjs/router";
import { JSXElement, Show, useContext } from "solid-js";
import { LoginContext } from "../Context/GlobalState";
-import { Home, Plus } from "../Util/Icons";
+import { Plus } from "../Util/Icons";
// Represents a single list item in the menu bar
export function MenuItem(props: {
@@ -23,7 +23,7 @@ export function Menu(): JSXElement {
const login_ctx = useContext(LoginContext)!;
return (
-
+
diff --git a/client-solid/src/Components/NewComment.tsx b/client-solid/src/Components/NewComment.tsx
index 61bc164..490250d 100644
--- a/client-solid/src/Components/NewComment.tsx
+++ b/client-solid/src/Components/NewComment.tsx
@@ -4,26 +4,23 @@ 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.
* @returns {JSXElement} A JSXElement that contains a textarea and a submit button.
*/
-export function NewCommentInputArea({
- parentPostId,
- parentCommentId,
-}: NewCommentInputAreaProps): JSXElement {
+
+interface NewCommentInputAreaProps {
+ parentPostId: number;
+ parentCommentId: number | null;
+}
+
+export function NewCommentInputArea(
+ props: NewCommentInputAreaProps
+): JSXElement {
const [content, setContent] = createSignal("");
const [waiting, setWaiting] = createSignal(false);
-
- // We assumte this context is always available
const login_ctx = useContext(LoginContext)!;
-
const nav = useNavigate();
const sendComment = (): void => {
@@ -32,15 +29,15 @@ export function NewCommentInputArea({
const response = createComment({
content: content(),
user_token: login_ctx.token(),
- parent_post_id: parentPostId,
- parent_comment_id: parentCommentId,
+ parent_post_id: props.parentPostId,
+ parent_comment_id: props.parentCommentId,
} as NewComment);
if (response) {
response.then(() => {
setWaiting(false);
setContent("");
- nav("/post/" + parentPostId);
+ nav("/post/" + props.parentPostId);
});
}
};
diff --git a/client-solid/src/Components/PostSegment.tsx b/client-solid/src/Components/PostSegment.tsx
index 9aea9e4..3525e31 100644
--- a/client-solid/src/Components/PostSegment.tsx
+++ b/client-solid/src/Components/PostSegment.tsx
@@ -1,22 +1,15 @@
import { JSXElement, Show } from "solid-js";
import { Post } from "../Util/api";
-import EngagementButton from "./Buttons/Engegament";
import CommentsBUtton from "./Buttons/CommentsButton";
+import EngagementButton from "./Buttons/Engegament";
+import RemovePostButton from "./Buttons/RemovePostButton";
import ReportButton from "./Buttons/Report";
import ToPostButton from "./Buttons/ToPost";
-import RemovePostButton from "./Buttons/RemovePostButton";
-/**
- * PostSegment is used to display posts in both the main feed and the post view
- *
- * @param {Object} props The properties for the PostSegment component.
- * @param {Post} props.post The post to display.
- * @returns {JSXElement} A JSXElement of a post
- */
-export function PostSegment({ post }: { post: Post }): JSXElement {
- const dateOfCreation = new Date(post.createdAt).toDateString();
- const isEdited = !(post.createdAt == post.updatedAt);
+export function PostSegment(props: { post: Post }): JSXElement {
+ const dateOfCreation = new Date(props.post.createdAt).toDateString();
+ const isEdited = !(props.post.createdAt == props.post.updatedAt);
return (
@@ -25,12 +18,12 @@ export function PostSegment({ post }: { post: Post }): JSXElement {
{dateOfCreation}
...
-
+
-
+
@@ -38,13 +31,13 @@ export function PostSegment({ post }: { post: Post }): JSXElement {
This post has been edited
-
{post.content}
+
{props.post.content}
-
-
+
+
-
+
diff --git a/client-solid/src/Util/api.ts b/client-solid/src/Util/api.ts
index be6d0f9..3284805 100644
--- a/client-solid/src/Util/api.ts
+++ b/client-solid/src/Util/api.ts
@@ -91,9 +91,7 @@ export async function getComments(
}
/** Incomplete */
-export async function engagePost(
- postId: string
-): Promise {
+export async function engagePost(postId: string): Promise {
const res = await fetch(`/api/engage_post?post_id=${postId}`);
const data = await res.json();
return data;