diff --git a/client-solid/src/Components/Buttons/CommentsButton.tsx b/client-solid/src/Components/Buttons/CommentsButton.tsx
index 3895d18..5f9c23a 100644
--- a/client-solid/src/Components/Buttons/CommentsButton.tsx
+++ b/client-solid/src/Components/Buttons/CommentsButton.tsx
@@ -7,7 +7,7 @@ export default function CommentsButton(): JSXElement {
);
diff --git a/client-solid/src/Components/Buttons/Engegament.tsx b/client-solid/src/Components/Buttons/Engegament.tsx
index de87ae5..11b49d8 100644
--- a/client-solid/src/Components/Buttons/Engegament.tsx
+++ b/client-solid/src/Components/Buttons/Engegament.tsx
@@ -1,31 +1,28 @@
-import { JSXElement, createSignal,onMount,useContext } from "solid-js";
+import { JSXElement, createSignal, onMount, useContext } from "solid-js";
-import { EngagementIcon } from "../../Util/Icons";
-import { engage } from "../../Util/api";
import { LoginContext } from "../../Context/GlobalState";
-import { getEngagementCount } from "../../Util/api";
+import { EngagementIcon } from "../../Util/Icons";
+import { engage, getEngagementCount } from "../../Util/api";
-export default function EngagementButton({
- postId,
-}: {
+export default function EngagementButton(props: {
postId: string;
}): JSXElement {
const [engagementCount, setEngagementCount] = createSignal(0);
const login_ctx = useContext(LoginContext)!;
onMount((): void => {
- void setUp()
- })
+ void setUp();
+ });
- const setUp = async () => {
- const r = await getEngagementCount(postId)
- setEngagementCount(r)
- }
+ const setUp = async (): Promise => {
+ const r = await getEngagementCount(props.postId);
+ setEngagementCount(r);
+ };
// Function to handle engagement
- const handleEngagement = async () => {
+ const handleEngagement = async (): Promise => {
try {
- const response = await engage(postId, login_ctx.token()) ;
+ const response = await engage(props.postId, login_ctx.token());
if (response.ok) {
// Update engagement count if the request is successful
setEngagementCount(await response.json());
@@ -47,7 +44,7 @@ export default function EngagementButton({
-
+
);
diff --git a/client-solid/src/Components/Buttons/RemovePostButton.tsx b/client-solid/src/Components/Buttons/RemovePostButton.tsx
index 50595f9..7c00c75 100644
--- a/client-solid/src/Components/Buttons/RemovePostButton.tsx
+++ b/client-solid/src/Components/Buttons/RemovePostButton.tsx
@@ -1,18 +1,44 @@
-import { JSXElement } from "solid-js";
+import { useNavigate } from "@solidjs/router";
+import { JSXElement, useContext } from "solid-js";
+import { LoginContext } from "../../Context/GlobalState";
import { RemovePostIcon } from "../../Util/Icons";
+import { deletePost } from "../../Util/api";
+
+export default function RemovePostButton(props: {
+ postId: string;
+}): JSXElement {
+ const navigate = useNavigate();
+ const login_ctx = useContext(LoginContext)!;
+
+ // Function to handle post deletion
+ const handleDeletePost = async (): Promise => {
+ try {
+ const response = await deletePost(props.postId, login_ctx.token());
+ if (response.ok) {
+ // If deletion is successful, navigate to "/" or remount the component
+ console.log("Post deleted successfully");
+ navigate("/"); // Redirect to "/" after successful deletion
+ } else {
+ // If deletion fails, handle the error
+ console.error("Failed to delete post:", response.statusText);
+ // You may want to show an error message or handle the failure in some other way
+ }
+ } catch (error) {
+ console.error("Error deleting post:", error);
+ // Handle any unexpected errors that occur during the deletion process
+ }
+ };
-export default function RemovePostButton(): JSXElement {
return (
- <>
-
-
-
- >
+
+
+
);
}
diff --git a/client-solid/src/Components/Comment.tsx b/client-solid/src/Components/Comment.tsx
index 9838fb4..325d164 100644
--- a/client-solid/src/Components/Comment.tsx
+++ b/client-solid/src/Components/Comment.tsx
@@ -13,7 +13,7 @@ export function Comment(props: CommentProps): JSXElement {
{props.comment.content}
-
+
>
);
}
diff --git a/client-solid/src/Components/PostSegment.tsx b/client-solid/src/Components/PostSegment.tsx
index cfc62dd..e3bbd71 100644
--- a/client-solid/src/Components/PostSegment.tsx
+++ b/client-solid/src/Components/PostSegment.tsx
@@ -1,4 +1,5 @@
import { JSXElement, Show } from "solid-js";
+
import { Post } from "../Util/api";
import CommentsButton from "./Buttons/CommentsButton";
import EngagementButton from "./Buttons/Engegament";
@@ -23,7 +24,7 @@ export function PostSegment(props: { post: Post }): JSXElement {
-
+