diff --git a/app/(tabs)/bookmark/page.tsx b/app/(tabs)/bookmark/page.tsx index a54c709..d73fc40 100644 --- a/app/(tabs)/bookmark/page.tsx +++ b/app/(tabs)/bookmark/page.tsx @@ -1,7 +1,87 @@ -import React from "react"; +"use client"; -const page = () => { - return
page
; +import React, { useState, useEffect } from "react"; +import BackgroundWrapper from "@/components/BackgroundWrapper"; +import { Bookmark, BookmarkCheck, ListFilter, MoveLeft } from "lucide-react"; +import { useRouter } from "next/navigation"; + +interface Question { + id: number; + question: string; + options: Record; +} + +interface QuestionItemProps { + question: Question; +} + +const QuestionItem = ({ question }: QuestionItemProps) => { + const [bookmark, setBookmark] = useState(true); + return ( +
+

+ {question.id + 1}. {question.question} +

+
+
+ +
+
+ {Object.entries(question.options).map(([key, value]) => { + return ( +
+ + {key.toUpperCase()} + + {value} +
+ ); + })} +
+
+ ); }; -export default page; +const BookmarkPage = () => { + const router = useRouter(); + const [questions, setQuestions] = useState(); + + useEffect(() => { + fetch("/data/bookmark.json") + .then((res) => res.json()) + .then((data) => setQuestions(data)) + .catch((err) => console.error("Error loading questions: ", err)); + }, []); + + return ( + +
+
+
+ +

Bookmark

+
+

Recent

+ +
+ {questions?.map((question) => ( + + ))} +
+
+
+
+ ); +}; + +export default BookmarkPage; diff --git a/app/(tabs)/layout.tsx b/app/(tabs)/layout.tsx index 12fdfcb..2fd6a8e 100644 --- a/app/(tabs)/layout.tsx +++ b/app/(tabs)/layout.tsx @@ -5,13 +5,19 @@ import Link from "next/link"; import { ReactNode } from "react"; import { usePathname } from "next/navigation"; import clsx from "clsx"; -import { House, LayoutGrid, Bookmark, CircleUser } from "lucide-react"; +import { + House, + LayoutGrid, + Bookmark, + CircleUser, + Settings, +} from "lucide-react"; const tabs = [ { name: "Home", href: "/home", component: }, { name: "Unit", href: "/unit", component: }, { name: "Bookmark", href: "/bookmark", component: }, - { name: "Profile", href: "/profile", component: }, + { name: "Settings", href: "/settings", component: }, ]; export default function TabsLayout({ children }: { children: ReactNode }) { diff --git a/app/(tabs)/profile/page.tsx b/app/(tabs)/profile/page.tsx deleted file mode 100644 index a54c709..0000000 --- a/app/(tabs)/profile/page.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; - -const page = () => { - return
page
; -}; - -export default page; diff --git a/app/(tabs)/settings/page.tsx b/app/(tabs)/settings/page.tsx new file mode 100644 index 0000000..b268f73 --- /dev/null +++ b/app/(tabs)/settings/page.tsx @@ -0,0 +1,79 @@ +"use client"; + +import BackgroundWrapper from "@/components/BackgroundWrapper"; +import { Avatar, AvatarFallback } from "@/components/ui/avatar"; +import { API_URL, getToken } from "@/lib/auth"; +import { MoveLeft, UserCircle2 } from "lucide-react"; +import Image from "next/image"; +import { useRouter } from "next/navigation"; +import React, { useEffect, useState } from "react"; + +const SettingsPage = () => { + const router = useRouter(); + const [userData, setUserData] = useState(null); + + useEffect(() => { + async function fetchUser() { + try { + const token = await getToken(); + if (!token) return; + + const response = await fetch(`${API_URL}/me`, { + method: "GET", + headers: { + Authorization: `Bearer ${token}`, + }, + }); + + if (response.ok) { + const fetchedUserData = await response.json(); + setUserData(fetchedUserData); + console.log(fetchedUserData); + } + } catch (error) { + console.error("Error fetching user data: ", error); + } + } + + fetchUser(); + }, []); + + return ( + +
+
+
+
+ +

+ Settings +

+ +
+
+
+ + + {userData?.name + ? userData.name.charAt(0).toUpperCase() + : ""} + + +
+

{userData?.name}

+

{userData?.email}

+
+
+
+
+
+
+
+ ); +}; + +export default SettingsPage; diff --git a/app/exam/pretest/page.tsx b/app/exam/pretest/page.tsx index d9c1290..04f7a01 100644 --- a/app/exam/pretest/page.tsx +++ b/app/exam/pretest/page.tsx @@ -79,21 +79,8 @@ export default function PretestPage() { ); } - const { isHydrated, isInitialized, currentExam } = useExam(); - - useEffect(() => { - console.log( - "hydrated:", - isHydrated, - "initialized:", - isInitialized, - "exam:", - currentExam - ); - }, [isHydrated, isInitialized, currentExam]); function handleStartExam() { - console.log(id); setCurrentExam(examData); startExam(); router.push(`/exam/${id}?time=${metadata?.metadata.duration}`); diff --git a/public/data/bookmark.json b/public/data/bookmark.json new file mode 100644 index 0000000..bb8dc35 --- /dev/null +++ b/public/data/bookmark.json @@ -0,0 +1,152 @@ +[ + { + "id": 0, + "question": "What is the gravitational acceleration on Earth's surface?", + "options": { + "a": "8.9 m/s²", + "b": "9.8 m/s²", + "c": "10.5 m/s²", + "d": "11.2 m/s²" + } + }, + { + "id": 1, + "question": "Which planet is known as the Red Planet?", + "options": { + "a": "Venus", + "b": "Jupiter", + "c": "Mars", + "d": "Saturn" + } + }, + { + "id": 2, + "question": "What is the chemical symbol for gold?", + "options": { + "a": "Go", + "b": "Gd", + "c": "Au", + "d": "Ag" + } + }, + { + "id": 3, + "question": "How many chambers does a human heart have?", + "options": { + "a": "2", + "b": "3", + "c": "4", + "d": "5" + } + }, + { + "id": 4, + "question": "What is the speed of light in a vacuum?", + "options": { + "a": "299,792,458 m/s", + "b": "300,000,000 m/s", + "c": "298,000,000 m/s", + "d": "301,000,000 m/s" + } + }, + { + "id": 5, + "question": "Which gas makes up approximately 78% of Earth's atmosphere?", + "options": { + "a": "Oxygen", + "b": "Carbon dioxide", + "c": "Nitrogen", + "d": "Argon" + } + }, + { + "id": 6, + "question": "What is the hardest natural substance on Earth?", + "options": { + "a": "Quartz", + "b": "Diamond", + "c": "Graphite", + "d": "Titanium" + } + }, + { + "id": 7, + "question": "How many bones are in an adult human body?", + "options": { + "a": "196", + "b": "206", + "c": "216", + "d": "226" + } + }, + { + "id": 8, + "question": "What is the pH of pure water?", + "options": { + "a": "6", + "b": "7", + "c": "8", + "d": "9" + } + }, + { + "id": 9, + "question": "Which organelle is known as the powerhouse of the cell?", + "options": { + "a": "Nucleus", + "b": "Ribosome", + "c": "Mitochondria", + "d": "Golgi apparatus" + } + }, + { + "id": 10, + "question": "What is the most abundant element in the universe?", + "options": { + "a": "Helium", + "b": "Hydrogen", + "c": "Oxygen", + "d": "Carbon" + } + }, + { + "id": 11, + "question": "At what temperature does water boil at sea level?", + "options": { + "a": "90°C", + "b": "95°C", + "c": "100°C", + "d": "105°C" + } + }, + { + "id": 12, + "question": "How many chromosomes do humans have?", + "options": { + "a": "44", + "b": "46", + "c": "48", + "d": "50" + } + }, + { + "id": 13, + "question": "What is the smallest unit of matter?", + "options": { + "a": "Molecule", + "b": "Atom", + "c": "Electron", + "d": "Proton" + } + }, + { + "id": 14, + "question": "Which type of electromagnetic radiation has the longest wavelength?", + "options": { + "a": "X-rays", + "b": "Visible light", + "c": "Radio waves", + "d": "Gamma rays" + } + } +]