diff --git a/apps/admin/data/fitai.db b/apps/admin/data/fitai.db index c8b73bf..d803238 100644 Binary files a/apps/admin/data/fitai.db and b/apps/admin/data/fitai.db differ diff --git a/apps/admin/src/app/api/admin/attendance/route.ts b/apps/admin/src/app/api/admin/attendance/route.ts index 3eb3059..4135941 100644 --- a/apps/admin/src/app/api/admin/attendance/route.ts +++ b/apps/admin/src/app/api/admin/attendance/route.ts @@ -10,7 +10,7 @@ export async function GET(req: Request) { const db = await getDatabase() const user = await db.getUserById(userId) - if (!user || user.role !== 'admin') { + if (!user || (user.role !== 'admin' && user.role !== 'superAdmin')) { return new NextResponse('Forbidden', { status: 403 }) } diff --git a/apps/admin/src/app/api/admin/stats/route.ts b/apps/admin/src/app/api/admin/stats/route.ts index 45e4eab..b419d6a 100644 --- a/apps/admin/src/app/api/admin/stats/route.ts +++ b/apps/admin/src/app/api/admin/stats/route.ts @@ -8,6 +8,12 @@ export async function GET() { if (!userId) return new NextResponse('Unauthorized', { status: 401 }) const db = await getDatabase() + const user = await db.getUserById(userId) + + if (!user || (user.role !== 'admin' && user.role !== 'superAdmin')) { + return new NextResponse('Forbidden', { status: 403 }) + } + const stats = await db.getDashboardStats() return NextResponse.json(stats) diff --git a/apps/mobile/src/app/(tabs)/index.tsx b/apps/mobile/src/app/(tabs)/index.tsx index 62b58cd..850d91e 100644 --- a/apps/mobile/src/app/(tabs)/index.tsx +++ b/apps/mobile/src/app/(tabs)/index.tsx @@ -75,6 +75,8 @@ export default function HomeScreen() { + + @@ -88,6 +90,7 @@ export default function HomeScreen() { + diff --git a/apps/mobile/src/app/fitness-profile.tsx b/apps/mobile/src/app/fitness-profile.tsx index 8e72ac7..46c7505 100644 --- a/apps/mobile/src/app/fitness-profile.tsx +++ b/apps/mobile/src/app/fitness-profile.tsx @@ -13,6 +13,7 @@ import { useAuth } from "@clerk/clerk-expo"; import { Ionicons } from "@expo/vector-icons"; import { Input } from "../components/Input"; import { Picker } from "../components/Picker"; +import { API_BASE_URL } from "../config/api"; interface FitnessProfileData { height?: number; @@ -64,7 +65,7 @@ export default function FitnessProfileScreen() { try { setFetchingProfile(true); const token = await getToken(); - const apiUrl = process.env.EXPO_PUBLIC_API_URL || "http://localhost:3000"; + const apiUrl = `${API_BASE_URL}` || "http://localhost:3000"; const response = await fetch(`${apiUrl}/api/fitness-profile`, { headers: { Authorization: `Bearer ${token}`, @@ -98,9 +99,9 @@ export default function FitnessProfileScreen() { try { setLoading(true); const token = await getToken(); - const apiUrl = process.env.EXPO_PUBLIC_API_URL || "http://localhost:3000"; + const apiUrl = `${API_BASE_URL}/api/fitness-profile` || "http://localhost:3000"; - const response = await fetch(`${apiUrl}/api/fitness-profile`, { + const response = await fetch(`${apiUrl}`, { method: "POST", headers: { "Content-Type": "application/json",