minir fix

This commit is contained in:
echo 2025-11-19 05:07:14 +01:00
parent a87b94219d
commit 4909815807
5 changed files with 14 additions and 4 deletions

Binary file not shown.

View File

@ -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 })
}

View File

@ -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)

View File

@ -75,6 +75,8 @@ export default function HomeScreen() {
<Ionicons name="chevron-forward" size={20} color="#9ca3af" />
</TouchableOpacity>
<View style={styles.actionButton}>
<View style={styles.actionIcon}>
<Ionicons name="log-in-outline" size={24} color="#2563eb" />
@ -88,6 +90,7 @@ export default function HomeScreen() {
<Ionicons name="chevron-forward" size={20} color="#9ca3af" />
</View>
<View style={styles.actionButton}>
<View style={styles.actionIcon}>
<Ionicons name="calendar-outline" size={24} color="#10b981" />

View File

@ -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",