You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mobile/app/(tabs)/(exercice)/WorkoutScreen.tsx

54 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import React, { useEffect, useState } from 'react';
import { View, ActivityIndicator, Text } from 'react-native';
import { useRouter } from 'expo-router';
import WorkoutPresentationComponent from "@/components/WorkoutPresentationComponent";
import {getExercices} from "@/api/services/ExercicesServices";
export default function WorkoutScreen() {
const router = useRouter();
const [exercices, setExercices] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
const loadExercices = async () => {
try {
const data = await getExercices();
setExercices(data);
} catch (err: any) {
setError(err.message);
} finally {
setLoading(false);
}
};
loadExercices();
}, []);
if (loading) {
return (
<View className="flex-1 justify-center items-center bg-black">
<ActivityIndicator size="large" color="#fff" />
</View>
);
}
if (error) {
return (
<View className="flex-1 justify-center items-center bg-black">
<Text className="text-red-500 text-xl">{error}</Text>
</View>
);
}
const workout = exercices[1]; // Choisis lexercice que tu souhaites afficher
return (
<View className="h-full rounded-2xl">
<WorkoutPresentationComponent workout={workout} dataExercise={exercices} router={router} />
</View>
);
}