+ nav("/post/" + post?.id)}
+ class="card bg-base-200 shadow-lg compact text-base-content w-full"
+ >
-
{post.content}
+
{post?.content}
);
}
-
diff --git a/client-solid/src/Primary.tsx b/client-solid/src/Primary.tsx
index 87d4da4..13d0eae 100644
--- a/client-solid/src/Primary.tsx
+++ b/client-solid/src/Primary.tsx
@@ -1,5 +1,6 @@
import { Route, Routes } from "@solidjs/router";
import { Posts } from "./Posts";
+import { SinglePost } from "./SinglePost";
import { NewPostInputArea } from "./Root";
// Primary is the section of the page that holds the main content
@@ -7,7 +8,9 @@ export function Primary() {
return (
} />
+ } />
} />
+ 404} />
);
}
diff --git a/client-solid/src/Root.tsx b/client-solid/src/Root.tsx
index 22e70ba..ef7aaa7 100644
--- a/client-solid/src/Root.tsx
+++ b/client-solid/src/Root.tsx
@@ -1,12 +1,12 @@
-import { Accessor, createSignal, useContext } from "solid-js";
+import { Accessor, Show, createSignal, useContext } from "solid-js";
import { createContext } from "solid-js";
-
import { createPost } from "./api";
import { NewPost } from "./api";
import { Navbar } from "./Navbar";
import { Primary } from "./Primary";
import { Login } from "./Navbar";
+import { useNavigate } from "@solidjs/router";
// Representing the state of varoious modals.
// So far we only have one modal, but we can add more later
@@ -59,34 +59,53 @@ function Root() {
export function NewPostInputArea() {
const [content, setContent] = createSignal("");
+ const [waiting, setWaiting] = createSignal(false);
const login_ctx = useContext(LoginContext);
+ const nav = useNavigate();
+
+ const sendPost = () => {
+ setWaiting(true);
+ const response = createPost({
+ content: content(),
+ token: login_ctx?.token(),
+ } as NewPost);
+ if (response) {
+ response.then(() => {
+ setWaiting(false);
+ setContent("");
+ nav("/");
+ });
+ }
+ };
+
return (
-
-
-
-
+
+ }
+ >
+
+
+
+
+
);
}
diff --git a/client-solid/src/SinglePost.tsx b/client-solid/src/SinglePost.tsx
new file mode 100644
index 0000000..b4440be
--- /dev/null
+++ b/client-solid/src/SinglePost.tsx
@@ -0,0 +1,19 @@
+import { useParams } from "@solidjs/router";
+import { Show, Suspense, createResource } from "solid-js";
+import { getPost } from "./api";
+import { PostSegment } from "./Posts";
+
+export function SinglePost() {
+ const params = useParams();
+ const [post] = createResource(params.postid, getPost);
+
+ return (
+ Some loading message