diff --git a/app/(quiz)/_layout.tsx b/app/(quiz)/_layout.tsx
new file mode 100644
index 0000000..b4ef1de
--- /dev/null
+++ b/app/(quiz)/_layout.tsx
@@ -0,0 +1,9 @@
+import { Stack } from "expo-router";
+
+export default function QuizLayout() {
+ return (
+
+
+
+ );
+}
diff --git a/app/(quiz)/quiz.tsx b/app/(quiz)/quiz.tsx
new file mode 100644
index 0000000..2de710c
--- /dev/null
+++ b/app/(quiz)/quiz.tsx
@@ -0,0 +1,144 @@
+import BackButton from "@/components/BackButton";
+import { toBgColor, toTextColor } from "@/components/Constants";
+import ActivityQuestion, {
+ ActivityQuestionRef,
+} from "@/components/quiz/ActivityQuestion";
+import AgeQuestion, { AgeQuestionRef } from "@/components/quiz/AgeQuestion";
+import BeginnerQuestion, {
+ BeginnerQuestionRef,
+} from "@/components/quiz/BeginnerQuestion";
+import FrequencyQuestion, {
+ FrequencyQuestionRef,
+} from "@/components/quiz/FrequencyQuestion";
+import GenderQuestion, {
+ GenderQuestionRef,
+} from "@/components/quiz/GenderQuestion";
+import GoalQuestion, { GoalQuestionRef } from "@/components/quiz/GoalQuestion";
+import HeightQuestion, {
+ HeightQuestionRef,
+} from "@/components/quiz/HeightQuestion";
+import SleepQuestion, {
+ SleepQuestionRef,
+} from "@/components/quiz/SleepQuestion";
+import SportQuestion, {
+ SportQuestionRef,
+} from "@/components/quiz/SportQuestion";
+import WeightQuestion, {
+ WeightQuestionRef,
+} from "@/components/quiz/WeightQuestion";
+import Button from "@/components/ui/Button";
+import Screen from "@/components/ui/Screen";
+import Text from "@/components/ui/Text";
+import { useSession } from "@/ctx";
+import { useRouter } from "expo-router";
+import React, { useRef, useState } from "react";
+import { View } from "react-native";
+
+export default function Quiz() {
+ const { signIn, session } = useSession();
+ const router = useRouter();
+
+ const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
+ const goalRef = useRef(null);
+ const genderRef = useRef(null);
+ const weightRef = useRef(null);
+ const heightRef = useRef(null);
+ const ageRef = useRef(null);
+ const beginnerRef = useRef(null);
+ const activityRef = useRef(null);
+ const frequencyRef = useRef(null);
+ const sportQuestionRef = useRef(null);
+ const sleepQuestionRef = useRef(null);
+
+ interface Question {
+ component: React.ForwardRefExoticComponent>;
+ props: T;
+ }
+
+ const questions: Question[] = [
+ { component: GoalQuestion, props: { ref: goalRef } },
+ { component: GenderQuestion, props: { ref: genderRef } },
+ {
+ component: WeightQuestion,
+ props: { ref: weightRef },
+ },
+ { component: HeightQuestion, props: { ref: heightRef } },
+ { component: AgeQuestion, props: { ref: ageRef } },
+ { component: BeginnerQuestion, props: { ref: beginnerRef } },
+ { component: ActivityQuestion, props: { ref: activityRef } },
+ //{ component: IllnessQuestion, props: {} },
+ {
+ component: FrequencyQuestion,
+ props: { ref: frequencyRef, isMale: genderRef.current?.getAnswer() },
+ },
+ { component: SportQuestion, props: { ref: sportQuestionRef } },
+ { component: SleepQuestion, props: { ref: sleepQuestionRef } },
+ ];
+
+ const goNext = () => {
+ if (currentQuestionIndex < questions.length - 1) {
+ setCurrentQuestionIndex(currentQuestionIndex + 1);
+ } else {
+ Collect();
+ }
+ };
+
+ function Collect() {
+ if (session) {
+ session.healthProblems = [];
+
+ session.goals = goalRef.current?.getAnswer();
+ session.sexe = genderRef.current?.getAnswer();
+ session.weight = weightRef.current?.getAnswer();
+ session.height = heightRef.current?.getAnswer();
+ session.age = ageRef.current?.getAnswer();
+ session.sportLevel = activityRef.current?.getAnswer();
+ session.nbSessionPerWeek = frequencyRef.current?.getAnswer();
+ session.sports = sportQuestionRef.current?.getAnswer();
+ session.sleepLevel = sleepQuestionRef.current?.getAnswer();
+ signIn(session);
+ }
+
+ router.replace("/(tabs)/(home)/HomeScreen");
+ }
+
+ return (
+
+
+
+ {
+ if (currentQuestionIndex === 0) {
+ router.replace("/(auth)/log-in");
+ } else {
+ setCurrentQuestionIndex((i) => Math.max(i - 1, 0));
+ }
+ }}
+ icon={currentQuestionIndex === 0 ? "close" : "arrowleft"}
+ />
+
+ Questionnaire
+
+
+
+ {currentQuestionIndex + 1} sur {questions.length}
+
+
+
+ {questions.map((question, index) =>
+ React.createElement(question.component, {
+ isVisible: index === currentQuestionIndex,
+ key: index,
+ ...question.props,
+ })
+ )}
+
+
+
+ );
+}
diff --git a/app/(tabs)/(add)/AddScreen.tsx b/app/(tabs)/(add)/AddScreen.tsx
index e420054..04f5310 100644
--- a/app/(tabs)/(add)/AddScreen.tsx
+++ b/app/(tabs)/(add)/AddScreen.tsx
@@ -1,13 +1,16 @@
import {SafeAreaView, View, Text} from "react-native";
import React from "react";
+import InternalError from "@/components/error/InternalErrorProblem";
export default function AddScreen() {
return (
- Welcome to Add Screen
- We will do it soon
+
);
-}
\ No newline at end of file
+}
+
+//Welcome to Add Screen
+// We will do it soon
\ No newline at end of file
diff --git a/app/(tabs)/(exercice)/ExercicesScreen.tsx b/app/(tabs)/(exercice)/ExercicesScreen.tsx
index 33494dd..96ca18e 100644
--- a/app/(tabs)/(exercice)/ExercicesScreen.tsx
+++ b/app/(tabs)/(exercice)/ExercicesScreen.tsx
@@ -1,54 +1,58 @@
-import React, { useEffect, useState } from 'react';
-import { FlatList, Text, TouchableOpacity, View } from 'react-native';
import { getExercices } from "@/api/services/ExercicesServices";
-import { useRouter } from "expo-router";
-import { Workout } from "@/model/Workout";
import WorkoutCardComponent from "@/components/WorkoutCardComponent";
+import { Workout } from "@/model/Workout";
+import { useRouter } from "expo-router";
+import React, { useEffect, useState } from "react";
+import { FlatList, Text, TouchableOpacity, View } from "react-native";
export default function ExercicesScreen() {
- const [exercices, setExercices] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
- const router = useRouter();
+ const [exercices, setExercices] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+ const router = useRouter();
- useEffect(() => {
- const fetchData = async () => {
- try {
- const data = await getExercices();
- setExercices(data);
- } catch (err: any) {
- setError(err.message);
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, []);
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ const data = await getExercices();
+ setExercices(data);
+ } catch (err: any) {
+ setError(err.message);
+ } finally {
+ setLoading(false);
+ }
+ };
- if (loading) {
- return Chargement...;
- }
+ fetchData();
+ }, []);
- if (error) {
- return Erreur : {error};
- }
+ if (loading) {
+ return Chargement...;
+ }
- return (
+ if (error) {
+ return Erreur : {error};
+ }
-
- item.id}
- renderItem={({ item }) => (
- router.push({ pathname: "/WorkoutScreen", params: { workout: JSON.stringify(item) } })}
- >
-
-
- )}
- />
-
- );
-}
\ No newline at end of file
+ return (
+
+ item.id}
+ renderItem={({ item }) => (
+
+ router.push({
+ pathname: "/WorkoutScreen",
+ params: { workout: JSON.stringify(item) },
+ })
+ }
+ >
+
+
+ )}
+ />
+
+ );
+}
diff --git a/app/(tabs)/(exercice)/WorkoutScreen.tsx b/app/(tabs)/(exercice)/WorkoutScreen.tsx
index 962055d..b4127c2 100644
--- a/app/(tabs)/(exercice)/WorkoutScreen.tsx
+++ b/app/(tabs)/(exercice)/WorkoutScreen.tsx
@@ -1,52 +1,56 @@
-import React, {useEffect, useState} from 'react';
-import {ActivityIndicator, Text, View} from 'react-native';
-import {useRouter} from 'expo-router';
+import { getExercices } from "@/api/services/ExercicesServices";
import WorkoutPresentationComponent from "@/components/WorkoutPresentationComponent";
-import {getExercices} from "@/api/services/ExercicesServices";
+import { useRouter } from "expo-router";
+import React, { useEffect, useState } from "react";
+import { ActivityIndicator, Text, View } from "react-native";
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 (
-
-
-
- );
- }
-
- if (error) {
- return (
-
- {error}
-
- );
- }
-
- const workout = exercices[1]; // Choisis l’exercice que tu souhaites afficher
+ 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 (
+
+
+
+ );
+ }
+ if (error) {
return (
-
-
-
+
+ {error}
+
);
+ }
+
+ const workout = exercices[1]; // Choisis l’exercice que tu souhaites afficher
+
+ return (
+
+
+
+ );
}
diff --git a/app/(tabs)/(help)/HelpsScreen.tsx b/app/(tabs)/(help)/HelpsScreen.tsx
index 48e20f0..c478b22 100644
--- a/app/(tabs)/(help)/HelpsScreen.tsx
+++ b/app/(tabs)/(help)/HelpsScreen.tsx
@@ -1,12 +1,12 @@
import {SafeAreaView, Text, View} from "react-native";
import React from "react";
+import Blocked from "@/components/error/BlockedProblem";
export default function HelpsScreen() {
return (
- Welcome to Help Screen
- We will do it soon
+
diff --git a/app/(tabs)/(home)/HomeScreen.tsx b/app/(tabs)/(home)/HomeScreen.tsx
index ce7a13b..d62cc43 100644
--- a/app/(tabs)/(home)/HomeScreen.tsx
+++ b/app/(tabs)/(home)/HomeScreen.tsx
@@ -1,78 +1,65 @@
-import {ScrollView, Text, View} from "react-native";
-import React, {useEffect, useState} from "react";
-import WorkoutCardComponent from "@/components/WorkoutCardComponent";
-import Screen from "@/components/ui/Screen";
+import { getExercices } from "@/api/services/ExercicesServices";
+import ActivitiesComponent from "@/components/ActivitiesComponent";
import CalendarComponent from "@/components/CalendarComponent";
import WelcomeComponent from "@/components/WelcomeComponent";
-import ActivitiesComponent from "@/components/ActivitiesComponent";
-import {Workout} from "@/model/Workout";
-import {getExercices} from "@/api/services/ExercicesServices";
-
+import WorkoutCardComponent from "@/components/WorkoutCardComponent";
+import Screen from "@/components/ui/Screen";
+import { Workout } from "@/model/Workout";
+import React, { useEffect, useState } from "react";
+import { ScrollView, Text, View } from "react-native";
export default function HomeScreen() {
+ const [exercices, setExercices] = useState([]);
- const [exercices, setExercices] = useState([]);
-
- const getRandomNumber = (min: number, max: number) => {
- return Math.floor(Math.random() * (max - min + 1)) + min;
+ const getRandomNumber = (min: number, max: number) => {
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+ };
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ const data = await getExercices();
+ setExercices(data);
+ } catch (err: any) {}
};
- useEffect(() => {
- const fetchData = async () => {
- try {
- const data = await getExercices();
- setExercices(data);
- } catch (err: any) {
-
- }
- };
-
- fetchData();
- }, []);
-
- return (
-
-
+ fetchData();
+ }, []);
-
-
-
+ return (
+
+
+
+
+
-
-
-
- Fitness Metrics
-
-
- See All
-
-
-
-
+
+
+
+ Fitness Metrics
+
+ See All
+
+
+
-
-
-
- Workout
-
-
- See All
-
-
-
-
+
+
+ Workout
+ See All
+
+
+
-
-
-
- Activities
-
-
- See All
-
-
-
-
-
-
- );
-}
\ No newline at end of file
+
+
+ Activities
+ See All
+
+
+
+
+
+ );
+}
diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx
index f6ff288..cd8fd2d 100644
--- a/app/(tabs)/_layout.tsx
+++ b/app/(tabs)/_layout.tsx
@@ -1,26 +1,26 @@
-import {Redirect, Tabs, useRouter} from "expo-router";
import { useSession } from "@/ctx";
-import React from "react";
import { AntDesign, Ionicons, MaterialIcons } from "@expo/vector-icons";
+import { Redirect, Tabs, useRouter } from "expo-router";
+import React from "react";
import Loading from "../loading";
export default function TabBarLayout() {
const { session, isLoading } = useSession();
- const router = useRouter()
+ const router = useRouter();
const sizeIcon = 24;
- // You can keep the splash screen open, or render a loading screen like we do here.
if (isLoading) {
return ;
}
- // Only require authentication within the (app) group's layout as users
- // need to be able to access the (auth) group and sign in again.
if (!session) {
- // On web, static rendering will stop here as the user is not authenticated
- // in the headless Node process that the pages are rendered in.
- return ;
+ return ;
}
+ console.log(session);
+ if (!session.isQuizDone()) {
+ return ;
+ }
+
return (
(({className, ...Props}, ref) => {
+ return (
+
+
+
+
+
+
+
+
+
+ {Props.problem}
+ {Props.description}
+
+
+
+ {Props.information}
+
+
+
+ );
+});
\ No newline at end of file
diff --git a/app/+not-found.tsx b/app/+not-found.tsx
index 7b07a8a..dcac0d4 100644
--- a/app/+not-found.tsx
+++ b/app/+not-found.tsx
@@ -14,19 +14,6 @@ export default function NotFoundScreen() {