-
-
-
-
+
+
+
);
}
diff --git a/client-solid/src/Navbar.tsx b/client-solid/src/Navbar.tsx
index a862e1e..2ed5fea 100644
--- a/client-solid/src/Navbar.tsx
+++ b/client-solid/src/Navbar.tsx
@@ -1,7 +1,8 @@
-import { JSXElement, createEffect, createSignal, useContext } from "solid-js";
+import { JSXElement, Show, useContext } from "solid-js";
import { A } from "@solidjs/router";
import { LoginContext } from "./Root";
import { ModalContext } from "./Root";
+import { Flake, Home, Plus, UserCircle } from "./Icons";
// Represents a single list item in the menu bar
function MenuItem(props: { href: string; children: JSXElement }): JSXElement {
@@ -19,8 +20,14 @@ function Menu(): JSXElement {
const login_ctx = useContext(LoginContext);
return (
);
}
@@ -28,7 +35,6 @@ function Menu(): JSXElement {
export function Navbar(): JSXElement {
const modal_ctx = useContext(ModalContext);
const login_ctx = useContext(LoginContext);
- const [buttonText, setButtonText] = createSignal("Login");
const logout = (): void => {
localStorage.removeItem("token");
@@ -37,17 +43,6 @@ export function Navbar(): JSXElement {
login_ctx?.setUsername("");
};
- // Function to instantly elect 50 cent as president and declare war on north korea
- const capitalizeFirst = (str: string): string => {
- return str.charAt(0).toUpperCase() + str.slice(1);
- };
-
- createEffect(() => {
- if (login_ctx?.token() != "")
- setButtonText(capitalizeFirst(login_ctx?.username() ?? "") + " (Logout)");
- else setButtonText("Login");
- }, 0);
-
const clickHandler = (): void => {
if (login_ctx?.token() != "") logout();
else modal_ctx?.setLoginModalOpen(true);
@@ -56,7 +51,8 @@ export function Navbar(): JSXElement {
return (
@@ -66,10 +62,15 @@ export function Navbar(): JSXElement {
diff --git a/client-solid/src/NewPost.tsx b/client-solid/src/NewPost.tsx
index 33f62c5..552e237 100644
--- a/client-solid/src/NewPost.tsx
+++ b/client-solid/src/NewPost.tsx
@@ -1,4 +1,4 @@
-import { JSXElement, Show, createSignal, useContext } from "solid-js";
+import { JSXElement, Show, createSignal, onMount, useContext } from "solid-js";
import { createPost } from "./api";
import { NewPost } from "./api";
import { useNavigate } from "@solidjs/router";
@@ -28,6 +28,10 @@ export function NewPostInputArea(): JSXElement {
}
};
+ onMount(() => {
+ if (login_ctx?.token() == "") nav("/");
+ });
+
return (
- {posts().map((post) => {
- return ;
- })}
+
+ {(post): JSXElement => }
+
);
}
@@ -27,7 +27,7 @@ export function Posts(): JSXElement {
export function PostSegment({ post }: { post: Post }): JSXElement {
const nav = useNavigate();
return (
-