minir fix
This commit is contained in:
parent
a87b94219d
commit
4909815807
Binary file not shown.
@ -10,7 +10,7 @@ export async function GET(req: Request) {
|
|||||||
const db = await getDatabase()
|
const db = await getDatabase()
|
||||||
const user = await db.getUserById(userId)
|
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 })
|
return new NextResponse('Forbidden', { status: 403 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,12 @@ export async function GET() {
|
|||||||
if (!userId) return new NextResponse('Unauthorized', { status: 401 })
|
if (!userId) return new NextResponse('Unauthorized', { status: 401 })
|
||||||
|
|
||||||
const db = await getDatabase()
|
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()
|
const stats = await db.getDashboardStats()
|
||||||
|
|
||||||
return NextResponse.json(stats)
|
return NextResponse.json(stats)
|
||||||
|
|||||||
@ -75,6 +75,8 @@ export default function HomeScreen() {
|
|||||||
<Ionicons name="chevron-forward" size={20} color="#9ca3af" />
|
<Ionicons name="chevron-forward" size={20} color="#9ca3af" />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<View style={styles.actionButton}>
|
<View style={styles.actionButton}>
|
||||||
<View style={styles.actionIcon}>
|
<View style={styles.actionIcon}>
|
||||||
<Ionicons name="log-in-outline" size={24} color="#2563eb" />
|
<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" />
|
<Ionicons name="chevron-forward" size={20} color="#9ca3af" />
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|
||||||
<View style={styles.actionButton}>
|
<View style={styles.actionButton}>
|
||||||
<View style={styles.actionIcon}>
|
<View style={styles.actionIcon}>
|
||||||
<Ionicons name="calendar-outline" size={24} color="#10b981" />
|
<Ionicons name="calendar-outline" size={24} color="#10b981" />
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { useAuth } from "@clerk/clerk-expo";
|
|||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { Input } from "../components/Input";
|
import { Input } from "../components/Input";
|
||||||
import { Picker } from "../components/Picker";
|
import { Picker } from "../components/Picker";
|
||||||
|
import { API_BASE_URL } from "../config/api";
|
||||||
|
|
||||||
interface FitnessProfileData {
|
interface FitnessProfileData {
|
||||||
height?: number;
|
height?: number;
|
||||||
@ -64,7 +65,7 @@ export default function FitnessProfileScreen() {
|
|||||||
try {
|
try {
|
||||||
setFetchingProfile(true);
|
setFetchingProfile(true);
|
||||||
const token = await getToken();
|
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`, {
|
const response = await fetch(`${apiUrl}/api/fitness-profile`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -98,9 +99,9 @@ export default function FitnessProfileScreen() {
|
|||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const token = await getToken();
|
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",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user