diff --git a/app/(tabs)/home/page.tsx b/app/(tabs)/home/page.tsx index 0f279e6..392fae5 100644 --- a/app/(tabs)/home/page.tsx +++ b/app/(tabs)/home/page.tsx @@ -144,8 +144,7 @@ const HomePage = () => { {/* Leaderboard Section */}

Leaderboard

-

Coming Soon.

- {/*
+
Top 3
- {boardError ? ( + {/* {boardError ? ( ) : ( getTopThree(boardData).map((student, idx) => ( @@ -174,9 +173,10 @@ const HomePage = () => {
)) - )} + )} */} +

Coming soon

-
*/} +
{/* Performance Summary Section */} diff --git a/app/(tabs)/profile/page.tsx b/app/(tabs)/profile/page.tsx index 76b5b44..8b33d3c 100644 --- a/app/(tabs)/profile/page.tsx +++ b/app/(tabs)/profile/page.tsx @@ -20,7 +20,7 @@ const ProfilePage = () => { const token = await getToken(); if (!token) return; - const response = await fetch(`${API_URL}/me`, { + const response = await fetch(`${API_URL}/me/profile/`, { method: "GET", headers: { Authorization: `Bearer ${token}`, @@ -79,7 +79,9 @@ const ProfilePage = () => {
- {userData?.name ? userData.name.charAt(0).toUpperCase() : ""} + {userData?.username + ? userData.username.charAt(0).toUpperCase() + : ""} diff --git a/app/(tabs)/settings/page.tsx b/app/(tabs)/settings/page.tsx index 212def5..7b25f13 100644 --- a/app/(tabs)/settings/page.tsx +++ b/app/(tabs)/settings/page.tsx @@ -24,12 +24,18 @@ import React, { useEffect, useState } from "react"; const SettingsPage = () => { const router = useRouter(); const [userData, setUserData] = useState({ - name: "", - institution: "", - sscRoll: "", - hscRoll: "", + user_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + username: "", + full_name: "", email: "", - phone: "", + is_verified: false, + phone_number: "", + ssc_roll: 0, + ssc_board: "", + hsc_roll: 0, + hsc_board: "", + college: "", + preparation_unit: "Science", }); useEffect(() => { @@ -38,7 +44,7 @@ const SettingsPage = () => { const token = await getToken(); if (!token) return; - const response = await fetch(`${API_URL}/me`, { + const response = await fetch(`${API_URL}/me/`, { method: "GET", headers: { Authorization: `Bearer ${token}`, @@ -75,13 +81,15 @@ const SettingsPage = () => {
- {userData?.name - ? userData.name.charAt(0).toUpperCase() + {userData?.username + ? userData.username.charAt(0).toUpperCase() : ""}
-

{userData?.name}

+

+ {userData?.full_name} +

{userData?.email}

diff --git a/components/Header.tsx b/components/Header.tsx index 198ea1b..9a2f379 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -53,7 +53,7 @@ const Header = ({ const token = await getToken(); if (!token) return; - const response = await fetch(`${API_URL}/me`, { + const response = await fetch(`${API_URL}/me/`, { method: "GET", headers: { Authorization: `Bearer ${token}`, @@ -100,11 +100,13 @@ const Header = ({
- {userData?.name ? userData.name.charAt(0).toUpperCase() : ""} + {userData?.username + ? userData.username.charAt(0).toUpperCase() + : ""} - Hello, {userData?.name ? userData.name.split(" ")[0] : ""} + Hello, {userData?.username ? userData.username.split(" ")[0] : ""}
)} diff --git a/components/ProfileManager.tsx b/components/ProfileManager.tsx index 9533474..03a9041 100644 --- a/components/ProfileManager.tsx +++ b/components/ProfileManager.tsx @@ -1,14 +1,6 @@ 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; -} +import { UserData } from "@/types/auth"; interface ProfileManagerProps { userData: UserData | undefined; @@ -23,57 +15,63 @@ export default function ProfileManager({ }: ProfileManagerProps) { if (!userData) return null; - const handleChange = (field: keyof UserData, value: string) => { + const handleChange = (field: keyof UserData, value: string | number) => { setUserData((prev) => (prev ? { ...prev, [field]: value } : prev)); }; return (
-
- - handleChange("name", e.target.value)} - className="bg-gray-50 py-6" - readOnly={!edit} - /> -
- + {/* Full Name */}
handleChange("institution", e.target.value)} + value={userData.full_name} + onChange={(e) => handleChange("full_name", e.target.value)} className="bg-gray-50 py-6" readOnly={!edit} />
+ {/* College */} +
+ + handleChange("college", e.target.value)} + className="bg-gray-50 py-6" + readOnly={!edit} + /> +
+ + {/* SSC & HSC Rolls */}
handleChange("sscRoll", e.target.value)} + id="ssc_roll" + type="number" + value={userData.ssc_roll} + onChange={(e) => handleChange("ssc_roll", Number(e.target.value))} className="bg-gray-50 py-6" readOnly={!edit} /> @@ -81,22 +79,23 @@ export default function ProfileManager({
handleChange("hscRoll", e.target.value)} + id="hsc_roll" + type="number" + value={userData.hsc_roll} + onChange={(e) => handleChange("hsc_roll", Number(e.target.value))} className="bg-gray-50 py-6" readOnly={!edit} />
+ {/* Email */}
+ {/* Phone */}
handleChange("phone", e.target.value)} + value={userData.phone_number} + onChange={(e) => handleChange("phone_number", e.target.value)} className="bg-gray-50 py-6" readOnly={!edit} /> diff --git a/lib/auth.ts b/lib/auth.ts index fddf0bb..29ec95b 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -28,7 +28,7 @@ export const login = async ( form: LoginForm, setToken: SetTokenFn ): Promise => { - const response = await fetch(`${API_URL}/auth/login`, { + const response = await fetch(`${API_URL}/auth/login/`, { method: "POST", headers: { "Content-Type": "application/json", @@ -50,7 +50,7 @@ export const register = async ( form: RegisterForm, setToken: SetTokenFn ): Promise => { - const response = await fetch(`${API_URL}/auth/register`, { + const response = await fetch(`${API_URL}/auth/register/`, { method: "POST", headers: { "Content-Type": "application/json", diff --git a/types/auth.d.ts b/types/auth.d.ts index abf69a0..9278740 100644 --- a/types/auth.d.ts +++ b/types/auth.d.ts @@ -1,10 +1,16 @@ export interface UserData { - name: string; - institution: string; - sscRoll: string; - hscRoll: string; + user_id: string; + username: string; + full_name: string; email: string; - phone: string; + is_verified: boolean; + phone_number: string; + ssc_roll: number; + ssc_board: string; + hsc_roll: number; + hsc_board: string; + college: string; + preparation_unit: "Science" | "Arts" | "Commerce" | string; } export interface RegisterForm {