-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filters VM and classroom to each page
- Loading branch information
1 parent
b21bcb3
commit c8ff1a2
Showing
7 changed files
with
166 additions
and
20 deletions.
There are no files selected for viewing
53 changes: 45 additions & 8 deletions
53
src/components/admin/dashboard-statistics/ClassroomStats.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,45 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import CountriesDropdown from './filters/CountriesDropdown'; | ||
import PhaseDropdown from './filters/PhaseDropdown'; | ||
import VillageDropdown from './filters/VillageDropdown'; | ||
import { mockClassroomsStats } from './mocks/mocks'; | ||
import { PelicoCard } from './pelico-card'; | ||
import styles from './styles/charts.module.css'; | ||
|
||
const VillageStats = () => { | ||
return null; | ||
const [selectedCountry, setSelectedCountry] = useState<string>(''); | ||
Check warning on line 11 in src/components/admin/dashboard-statistics/VillageStats.tsx GitHub Actions / lint
|
||
const [selectedVillage, setSelectedVillage] = useState<string>(''); | ||
|
||
const pelicoMessage = 'Merci de sélectionner un village-monde pour analyser ses statistiques '; | ||
|
||
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 villages = [...new Set(villagesMap)]; | ||
const handleVillageChange = (village: string) => { | ||
setSelectedVillage(village); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className={styles.filtersContainer}> | ||
<div className={styles.phaseFilter}> | ||
<PhaseDropdown /> | ||
</div> | ||
<div className={styles.countryFilter}> | ||
<CountriesDropdown countries={countries} onCountryChange={handleCountryChange} /> | ||
</div> | ||
<div className={'styles.countryFilter'}> | ||
<VillageDropdown villages={villages} onVillageChange={handleVillageChange} /> | ||
</div> | ||
</div> | ||
{!selectedVillage ? <PelicoCard message={pelicoMessage} /> : null} | ||
</> | ||
); | ||
}; | ||
|
||
export default VillageStats; |
38 changes: 38 additions & 0 deletions
38
src/components/admin/dashboard-statistics/filters/ClassroomDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
|
||
import Box from '@mui/material/Box'; | ||
import FormControl from '@mui/material/FormControl'; | ||
import InputLabel from '@mui/material/InputLabel'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import type { SelectChangeEvent } from '@mui/material/Select'; | ||
import Select from '@mui/material/Select'; | ||
|
||
interface ClassroomDropdownProps { | ||
classrooms: number[]; | ||
onClassroomChange: (classrooms: string) => void; | ||
} | ||
|
||
export default function ClassroomDropdown({ classrooms, onClassroomChange }: ClassroomDropdownProps) { | ||
const [classroom, setClassroom] = React.useState(''); | ||
|
||
const handleChange = (event: SelectChangeEvent) => { | ||
const selectedClassroom = event.target.value as string; | ||
setClassroom(selectedClassroom); | ||
onClassroomChange(selectedClassroom); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ minWidth: 150, maxWidth: 200 }}> | ||
<FormControl fullWidth size="small"> | ||
<InputLabel id="classroom-menu-select">Classe</InputLabel> | ||
<Select labelId="classroom-menu-select" id="classroom-select" value={classroom} label="Classe" onChange={handleChange}> | ||
{classrooms.map((classroom) => ( | ||
<MenuItem key={classroom} value={classroom}> | ||
{classroom} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/components/admin/dashboard-statistics/filters/VillageDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
|
||
import Box from '@mui/material/Box'; | ||
import FormControl from '@mui/material/FormControl'; | ||
import InputLabel from '@mui/material/InputLabel'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import type { SelectChangeEvent } from '@mui/material/Select'; | ||
import Select from '@mui/material/Select'; | ||
|
||
interface VillageDropdownProps { | ||
villages: string[]; | ||
onVillageChange: (vm: string) => void; | ||
} | ||
|
||
export default function VillageDropdown({ villages, onVillageChange }: VillageDropdownProps) { | ||
const [village, setVillage] = React.useState(''); | ||
|
||
const handleChange = (event: SelectChangeEvent) => { | ||
const selectedVillage = event.target.value as string; | ||
setVillage(selectedVillage); | ||
onVillageChange(selectedVillage); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ minWidth: 150, maxWidth: 200 }}> | ||
<FormControl fullWidth size="small"> | ||
<InputLabel id="village-menu-select">Village-monde</InputLabel> | ||
<Select labelId="village-menu-select" id="village-select" value={village} label="Village" onChange={handleChange}> | ||
{villages.map((village) => ( | ||
<MenuItem key={village} value={village}> | ||
{village} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters