From e05e135276dfabd68da8503349166cbff12ec7a6 Mon Sep 17 00:00:00 2001 From: Melissa Olas Date: Tue, 10 Sep 2024 16:19:50 +0200 Subject: [PATCH] adapt filter to country, VM condition for VM & classroom --- server/controllers/analytic.ts | 2 -- .../dashboard-statistics/ClassroomStats.tsx | 20 ++++++++++++++----- .../dashboard-statistics/VillageStats.tsx | 7 +++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/server/controllers/analytic.ts b/server/controllers/analytic.ts index a8128eac9..cb1232ce6 100644 --- a/server/controllers/analytic.ts +++ b/server/controllers/analytic.ts @@ -282,8 +282,6 @@ analyticController.router.post( AppDataSource.getRepository(User).createQueryBuilder('user').select('user.firstlogin').where({ id: data.userId }).getRawOne(), ]); - console.log('User Phase in analytics', userPhase); - if (sessionCount === 0 && data.event === 'pageview' && data.params?.isInitial) { const session = new AnalyticSession(); session.id = data.sessionId; diff --git a/src/components/admin/dashboard-statistics/ClassroomStats.tsx b/src/components/admin/dashboard-statistics/ClassroomStats.tsx index fe1b8e276..bedc807b9 100644 --- a/src/components/admin/dashboard-statistics/ClassroomStats.tsx +++ b/src/components/admin/dashboard-statistics/ClassroomStats.tsx @@ -16,17 +16,27 @@ const ClassroomStats = () => { const pelicoMessage = 'Merci de sélectionner une classe pour analyser ses statistiques '; const countriesMap = mockClassroomsStats.map((country) => country.classroomCountryCode); - const countries = [...new Set(countriesMap)]; // avoid duplicates + const countries = [...new Set(countriesMap)]; + const handleCountryChange = (country: string) => { setSelectedCountry(country); + setSelectedVillage(''); + setSelectedClassroom(''); }; - const villagesMap = mockClassroomsStats.map((village) => village.villageName); + + const villagesMap = mockClassroomsStats.filter((village) => village.classroomCountryCode === selectedCountry).map((village) => village.villageName); const villages = [...new Set(villagesMap)]; + const handleVillageChange = (village: string) => { setSelectedVillage(village); + setSelectedClassroom(''); }; - const classroomsMap = mockClassroomsStats.map((classroom) => classroom.classroomId); + + const classroomsMap = mockClassroomsStats + .filter((classroom) => classroom.villageName === selectedVillage) + .map((classroom) => classroom.classroomId); const classrooms = [...new Set(classroomsMap)]; + const handleClassroomChange = (classroom: string) => { setSelectedClassroom(classroom); }; @@ -40,10 +50,10 @@ const ClassroomStats = () => {
-
+
-
+
diff --git a/src/components/admin/dashboard-statistics/VillageStats.tsx b/src/components/admin/dashboard-statistics/VillageStats.tsx index 27f8add8b..9a6eb4be6 100644 --- a/src/components/admin/dashboard-statistics/VillageStats.tsx +++ b/src/components/admin/dashboard-statistics/VillageStats.tsx @@ -15,11 +15,14 @@ const VillageStats = () => { const countriesMap = mockClassroomsStats.map((country) => country.classroomCountryCode); const countries = [...new Set(countriesMap)]; // avoid duplicates + const handleCountryChange = (country: string) => { setSelectedCountry(country); }; - const villagesMap = mockClassroomsStats.map((village) => village.villageName); + + const villagesMap = mockClassroomsStats.filter((village) => village.classroomCountryCode === selectedCountry).map((village) => village.villageName); const villages = [...new Set(villagesMap)]; + const handleVillageChange = (village: string) => { setSelectedVillage(village); }; @@ -33,7 +36,7 @@ const VillageStats = () => {
-
+