fix(api): fix api endpoint logic #3

This commit is contained in:
shafin-r
2025-08-17 14:08:17 +06:00
parent ad46bf954e
commit 4f23f357e6
7 changed files with 87 additions and 69 deletions

View File

@ -24,12 +24,18 @@ import React, { useEffect, useState } from "react";
const SettingsPage = () => {
const router = useRouter();
const [userData, setUserData] = useState<UserData>({
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 = () => {
<div className="flex gap-4 items-center">
<Avatar className="bg-[#113768] w-20 h-20">
<AvatarFallback className="text-3xl text-white">
{userData?.name
? userData.name.charAt(0).toUpperCase()
{userData?.username
? userData.username.charAt(0).toUpperCase()
: ""}
</AvatarFallback>
</Avatar>
<div className="flex flex-col items-start">
<h1 className="font-semibold text-2xl">{userData?.name}</h1>
<h1 className="font-semibold text-2xl">
{userData?.full_name}
</h1>
<h3 className=" text-md">{userData?.email}</h3>
</div>
</div>