diff --git a/app/(tabs)/profile/page.tsx b/app/(tabs)/profile/page.tsx new file mode 100644 index 0000000..77f70a2 --- /dev/null +++ b/app/(tabs)/profile/page.tsx @@ -0,0 +1,94 @@ +"use client"; + +import ProfileManager from "@/components/ProfileManager"; +import { Avatar, AvatarFallback } from "@/components/ui/avatar"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { getToken, API_URL } from "@/lib/auth"; +import { ChevronLeft, Edit2, Lock, Save } from "lucide-react"; +import { useRouter } from "next/navigation"; +import React, { useEffect, useState } from "react"; + +interface UserData { + name: string; + institution: string; + sscRoll: string; + hscRoll: string; + email: string; + phone: string; +} + +const ProfilePage = () => { + const router = useRouter(); + + const [userData, setUserData] = useState(); + const [editStatus, setEditStatus] = useState(false); + + 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); + } + } catch (error) { + console.error("Error fetching user data: ", error); + } + } + + fetchUser(); + }, []); + + return ( +
+
+ +
+
+ + + {userData?.name ? userData.name.charAt(0).toUpperCase() : ""} + + +
+ + + +
+
+
+ ); +}; + +export default ProfilePage; diff --git a/app/(tabs)/settings/page.tsx b/app/(tabs)/settings/page.tsx index b268f73..757e8ba 100644 --- a/app/(tabs)/settings/page.tsx +++ b/app/(tabs)/settings/page.tsx @@ -3,8 +3,20 @@ 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 { + Bookmark, + ChartColumn, + ChevronRight, + Clock4, + CreditCard, + Crown, + Globe, + LogOut, + MapPin, + MoveLeft, + Trash2, + UserCircle2, +} from "lucide-react"; import { useRouter } from "next/navigation"; import React, { useEffect, useState } from "react"; @@ -28,7 +40,6 @@ const SettingsPage = () => { if (response.ok) { const fetchedUserData = await response.json(); setUserData(fetchedUserData); - console.log(fetchedUserData); } } catch (error) { console.error("Error fetching user data: ", error); @@ -63,12 +74,113 @@ const SettingsPage = () => { : ""} -
+

{userData?.name}

{userData?.email}

+
+ +
+
+ +

+ Bookmarks +

+
+ +
+
+
+ +

+ Payments +

+
+ +
+
+
+
+ +

+ Languages +

+
+ +
+
+
+ +

+ Location +

+
+ +
+
+
+ +

+ Subscription +

+
+ +
+
+
+ +

+ Performance +

+
+ +
+
+
+
+ +

+ Clear Cache +

+
+ +
+
+
+ +

+ Clear History +

+
+ +
+
+
+ +

+ Log out +

+
+ +
+
+

+ ExamJam | Version 1.0 +

+
diff --git a/bun.lockb b/bun.lockb index 053d8be..90fb462 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/ProfileManager.tsx b/components/ProfileManager.tsx new file mode 100644 index 0000000..bc98195 --- /dev/null +++ b/components/ProfileManager.tsx @@ -0,0 +1,129 @@ +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; + +interface UserData { + name: string; + institution: string; + sscRoll: string; + hscRoll: string; + email: string; + phone: string; +} + +interface ProfileManagerProps { + userData: UserData | undefined; + edit: boolean; +} + +export default function ProfileManager({ + userData, + edit, +}: ProfileManagerProps) { + return ( +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ ); +} diff --git a/components/ui/input.tsx b/components/ui/input.tsx new file mode 100644 index 0000000..03295ca --- /dev/null +++ b/components/ui/input.tsx @@ -0,0 +1,21 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +function Input({ className, type, ...props }: React.ComponentProps<"input">) { + return ( + + ) +} + +export { Input } diff --git a/components/ui/label.tsx b/components/ui/label.tsx new file mode 100644 index 0000000..fb5fbc3 --- /dev/null +++ b/components/ui/label.tsx @@ -0,0 +1,24 @@ +"use client" + +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" + +import { cn } from "@/lib/utils" + +function Label({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { Label } diff --git a/package.json b/package.json index caabb55..5097e8c 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@radix-ui/react-avatar": "^1.1.10", + "@radix-ui/react-label": "^2.1.7", "@radix-ui/react-slot": "^1.2.3", "capacitor-secure-storage-plugin": "^0.11.0", "clsx": "^2.1.1",