diff --git a/src/app/(app)/posts/page.tsx b/src/app/(app)/posts/page.tsx
index 574eff1..8c7204b 100644
--- a/src/app/(app)/posts/page.tsx
+++ b/src/app/(app)/posts/page.tsx
@@ -1,156 +1,150 @@
"use client";
-
-// HELP NOT WORKING -> import { useDevice } from "@/lib/context/DeviceContext"; USERNAME!!
-const useDevice = () => ({
- isAuthenticated: true,
- session: { username: "demo_user" },
- });
-
+import { useDevice } from "@/lib/context/DeviceContext";
import React, { useEffect, useState } from "react";
export default function PostsPage() {
- const [postText, setPostText] = useState("");
- const [posts, setPosts] = useState([]);
- const [userReactions, setUserReactions] = useState<{
- [index: number]: { liked: boolean; warned: boolean };
- }>({});
- const { isAuthenticated, session } = useDevice();
+ const [postText, setPostText] = useState("");
+ const [posts, setPosts] = useState([]);
+ const [userReactions, setUserReactions] = useState<{
+ [index: number]: { liked: boolean; warned: boolean };
+ }>({});
+ const { isAuthenticated, session } = useDevice();
- useEffect(() => {
- if (isAuthenticated && session?.username) {
- fetch(`/api/user/${session.username}`).then((res) => res.json());
- }
- }, [isAuthenticated, session?.username]);
+ useEffect(() => {
+ if (isAuthenticated && session?.username) {
+ fetch(`/api/user/${session.username}`).then((res) => res.json());
+ }
+ }, [isAuthenticated, session?.username]);
- const handlePostSubmit = (e: React.FormEvent) => {
- e.preventDefault();
- const newPost = {
- text: postText,
- date: new Date().toLocaleString(),
- likes: 0,
- warnings: 0,
- imageUrl: "", // placeholder for image logick
- author: session.username, // add username to track authorship
- };
- setPosts([newPost, ...posts]);
- setPostText("");
- };
+ const handlePostSubmit = (e: React.FormEvent) => {
+ e.preventDefault();
+ const newPost = {
+ text: postText,
+ date: new Date().toLocaleString(),
+ likes: 0,
+ warnings: 0,
+ imageUrl: "", // placeholder for image logick
+ author: session.username, // add username to track authorship
+ };
+ setPosts([newPost, ...posts]);
+ setPostText("");
+ };
- const handleLike = (index: number) => {
- const updatedPosts = [...posts];
- const reactions = { ...userReactions };
+ const handleLike = (index: number) => {
+ const updatedPosts = [...posts];
+ const reactions = { ...userReactions };
- const alreadyLiked = reactions[index]?.liked;
+ const alreadyLiked = reactions[index]?.liked;
- updatedPosts[index].likes += alreadyLiked ? -1 : 1;
+ updatedPosts[index].likes += alreadyLiked ? -1 : 1;
- reactions[index] = {
- ...reactions[index],
- liked: !alreadyLiked,
- };
+ reactions[index] = {
+ ...reactions[index],
+ liked: !alreadyLiked,
+ };
- setPosts(updatedPosts);
- setUserReactions(reactions);
- };
+ setPosts(updatedPosts);
+ setUserReactions(reactions);
+ };
- const handleWarning = (index: number) => {
- const updatedPosts = [...posts];
- const reactions = { ...userReactions };
+ const handleWarning = (index: number) => {
+ const updatedPosts = [...posts];
+ const reactions = { ...userReactions };
- const alreadyWarned = reactions[index]?.warned;
+ const alreadyWarned = reactions[index]?.warned;
- updatedPosts[index].warnings += alreadyWarned ? -1 : 1;
+ updatedPosts[index].warnings += alreadyWarned ? -1 : 1;
- reactions[index] = {
- ...reactions[index],
- warned: !alreadyWarned,
- };
+ reactions[index] = {
+ ...reactions[index],
+ warned: !alreadyWarned,
+ };
- setPosts(updatedPosts);
- setUserReactions(reactions);
- };
+ setPosts(updatedPosts);
+ setUserReactions(reactions);
+ };
- return (
-
-
-
- Posts
-
-
+ return (
+
+
+
+ Posts
+
+
-
-
-
+
+
+
-
- {posts.map((post, index) => (
-
-
-
-
-
- {post.author || "Anonymous"}
-
-
{post.date}
-
-
+
+ {posts.map((post, index) => (
+
+
+
+
+
+ {post.author || "Anonymous"}
+
+
{post.date}
+
+
- {post.imageUrl && (
-

- )}
+ {post.imageUrl && (
+

+ )}
-
{post.text}
+
{post.text}
-
-
-
-
-
- ))}
-
+
+
+
+
+
+ ))}
+
-
-
- );
+
+
+ );
}
diff --git a/src/app/(app)/profile/page.tsx b/src/app/(app)/profile/page.tsx
index 953ae74..9a79623 100644
--- a/src/app/(app)/profile/page.tsx
+++ b/src/app/(app)/profile/page.tsx
@@ -98,9 +98,6 @@ function Mobile() {
Don't forget you have a 400mg caffeine limit and 30.5g sugar limit!
-
-
-
);
}
diff --git a/src/lib/components/MobileNav.jsx b/src/lib/components/MobileNav.jsx
index d1a778d..b3971c5 100644
--- a/src/lib/components/MobileNav.jsx
+++ b/src/lib/components/MobileNav.jsx
@@ -6,6 +6,7 @@ import {
Home as IconHome,
BookText as BookImage,
User as UserImage,
+ Plus as PlusImage,
} from "lucide-react";
import { useDevice } from "@/lib/context/DeviceContext";
@@ -23,9 +24,14 @@ const MobileNav = () => {
{isAuthenticated ? (
-
-
-
+
) : null}