Skip to content

Commit

Permalink
linter mondification
Browse files Browse the repository at this point in the history
  • Loading branch information
dodoLaprovence committed Nov 11, 2024
1 parent c3cd756 commit 09b6c61
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 83 deletions.
14 changes: 6 additions & 8 deletions src/components/admin/dashboard-statistics/ClassroomStats.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
import React, { useState } from 'react';

import AccessTimeIcon from '@mui/icons-material/AccessTime';
import VisibilityIcon from '@mui/icons-material/Visibility';
import React, { useState } from 'react';

import AverageStatsCard from './cards/AverageStatsCard/AverageStatsCard';
import ClassesExchangesCard from './cards/ClassesExchangesCard/ClassesExchangesCard';
import ClassroomDetailsCard from './cards/ClassroomDetailsCard/ClassroomDetailsCard';
import CommentCard from './cards/CommentCard/CommentCard';
import BarCharts from './charts/BarCharts';
import CountriesDropdown from './filters/CountriesDropdown';
import Dropdown from './filters/Dropdown';
import PhaseDropdown from './filters/PhaseDropdown';
import PhaseDetails from './menu/PhaseDetails';
import { mockClassroomsStats, mockDataByMonth } from './mocks/mocks';
import styles from './styles/charts.module.css';
import { useStatisticsClassrooms, useStatisticsSessions } from 'src/services/useStatistics';
import type { ClassroomsStats, SessionsStats } from 'types/statistics.type';

const barChartData = [{ data: [4, 3, 5] }, { data: [1, 6, 3] }, { data: [2, 5, 6] }];
const BarChartTitle = 'Evolution des connexions';

const ClassroomStats = () => {
const [selectedCountry, setSelectedCountry] = useState<string>('');
const statisticsSessions: SessionsStats | Record<string, never> = useStatisticsSessions(null, null, 1);
const statisticsClassrooms = useStatisticsClassrooms(null, 'FR', null) as ClassroomsStats;
const statisticsClassrooms = useStatisticsClassrooms(null, selectedCountry, null) as ClassroomsStats;
const countriesMap = mockClassroomsStats.map((country) => country.classroomCountryCode);
const countries = [...new Set(countriesMap)]; // avoid duplicates
const handleCountryChange = (country: string) => {
Expand All @@ -36,13 +34,13 @@ const ClassroomStats = () => {
<PhaseDropdown />
</div>
<div className={styles.medFilter}>
<CountriesDropdown countries={countries} onCountryChange={handleCountryChange} label={'Tous les pays'} />
<Dropdown data={countries} onItemChange={handleCountryChange} label={'Tous les pays'} title="Pays" />
</div>
<div className={styles.medFilter}>
<CountriesDropdown countries={countries} onCountryChange={handleCountryChange} label={'Tous les pays'} />
<Dropdown data={countries} onItemChange={handleCountryChange} label={'Tous les villages'} title="Village" />
</div>
<div className={styles.medFilter}>
<CountriesDropdown countries={countries} onCountryChange={handleCountryChange} label={'Tous les pays'} />
<Dropdown data={countries} onItemChange={handleCountryChange} label={'Toutes les classes'} title="Classe" />
</div>
</div>
<CommentCard />
Expand Down
46 changes: 12 additions & 34 deletions src/components/admin/dashboard-statistics/CountryStats.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useState } from 'react';

import AccessTimeIcon from '@mui/icons-material/AccessTime';
import VisibilityIcon from '@mui/icons-material/Visibility';
import Box from '@mui/material/Box';
import React, { useState } from 'react';

import AverageStatsCard from './cards/AverageStatsCard/AverageStatsCard';
import ClassesExchangesCard from './cards/ClassesExchangesCard/ClassesExchangesCard';
Expand All @@ -12,10 +10,10 @@ import BarCharts from './charts/BarCharts';
import DashboardTable from './charts/DashboardTable';
import HorizontalBarsChart from './charts/HorizontalChart';
import PieCharts from './charts/PieCharts';
import CountriesDropdown from './filters/CountriesDropdown';
import Dropdown from './filters/Dropdown';
import PhaseDropdown from './filters/PhaseDropdown';
import PhaseDetails from './menu/PhaseDetails';
import { mockClassroomsStats, mockConnectionsStats, mockDataByMonth } from './mocks/mocks';
import { mockClassroomsStats, mockDataByMonth } from './mocks/mocks';
import styles from './styles/charts.module.css';
import { useStatisticsClassrooms, useStatisticsSessions } from 'src/services/useStatistics';
import type { ClassroomsStats, SessionsStats } from 'types/statistics.type';
Expand All @@ -28,49 +26,29 @@ const pieChartData = {
],
};

const barChartData = [{ data: [4, 3, 5] }, { data: [1, 6, 3] }, { data: [2, 5, 6] }];
const EngagementBarChartTitle = 'Évolution des connexions';
const ContributionBarChartTitle = 'Contribution des classes';

const CountryStats = () => {
const [selectedCountry, setSelectedCountry] = useState<string>('');
const statisticsClassrooms = useStatisticsClassrooms(null, 'FR', null) as ClassroomsStats;
const statisticsClassrooms = useStatisticsClassrooms(null, selectedCountry, null) as ClassroomsStats;
const statisticsSessions: SessionsStats | Record<string, never> = useStatisticsSessions(null, 'FR', null);

// const countriesMap = mockClassroomsStats.map((country) => country.classroomCountryCode);
// const countries = [...new Set(countriesMap)]; // avoid duplicates
// const handleCountryChange = (country: string) => {
// setSelectedCountry(country);
// };

// const filteredVillage = mockClassroomsStats.filter((village) => village.classroomCountryCode === selectedCountry);

// const classStats = mockConnectionsStats.map((classroom) => ({
// registered: classroom.registeredClassroomsCount,
// connected: classroom.connectedClassroomsCount,
// contributed: classroom.contributedClassroomsCount,
// }));

// const connectStats = mockConnectionsStats.map((connect) => ({
// averageConnection: connect.averageConnections,
// averageDuration: connect.averageDuration,
// minDuration: connect.minDuration,
// maxDuration: connect.maxDuration,
// medianDuration: connect.medianDuration,
// minConnections: connect.minConnections,
// maxConnections: connect.maxConnections,
// medianConnections: connect.medianConnections,
// }));
const countriesMap = mockClassroomsStats.map((country) => country.classroomCountryCode);
const countries = [...new Set(countriesMap)]; // avoid duplicates
const handleCountryChange = (country: string) => {
setSelectedCountry(country);
};

return (
<>
<div className={styles.filtersContainer}>
<div className={styles.smallFilter}>
<PhaseDropdown />
</div>
{/* <div className={styles.medFilter}>
<CountriesDropdown countries={countries} onCountryChange={handleCountryChange} label={'Tous les pays'} />
</div> */}
<div className={styles.medFilter}>
<Dropdown data={countries} onItemChange={handleCountryChange} label={'Tous les pays'} title="Pays" />
</div>
<div className={styles.medFilter} />
<div className={styles.medFilter} />
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/components/admin/dashboard-statistics/GlobalStats.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import AccessTimeIcon from '@mui/icons-material/AccessTime';
import VisibilityIcon from '@mui/icons-material/Visibility';
import React, { useContext } from 'react';
import React from 'react';

import type ClassroomStats from './ClassroomStats';
import AverageStatsCard from './cards/AverageStatsCard/AverageStatsCard';
import ClassesContributionCard from './cards/ClassesContributionCard/ClassesContributionCard';
import ClassesExchangesCard from './cards/ClassesExchangesCard/ClassesExchangesCard';
Expand Down
28 changes: 15 additions & 13 deletions src/components/admin/dashboard-statistics/VillageStats.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import AccessTimeIcon from '@mui/icons-material/AccessTime';
import VisibilityIcon from '@mui/icons-material/Visibility';
import { stat } from 'fs';
import React, { useContext, useState } from 'react';

import AverageStatsCard from './cards/AverageStatsCard/AverageStatsCard';
Expand All @@ -12,7 +11,7 @@ import BarCharts from './charts/BarCharts';
import DashboardTable from './charts/DashboardTable';
import DualBarChart from './charts/DualBarChart/DualBarChart';
import PieCharts from './charts/PieCharts';
import CountriesDropdown from './filters/CountriesDropdown';
import Dropdown from './filters/Dropdown';
import PhaseDropdown from './filters/PhaseDropdown';
import PhaseDetails from './menu/PhaseDetails';
import { mockClassroomsStats, mockDataByMonth } from './mocks/mocks';
Expand All @@ -23,18 +22,21 @@ import type { ClassroomsStats, SessionsStats } from 'types/statistics.type';

const VillageStats = () => {
const data = { data: [{ label: 'test1', id: 1, value: 1 }] };
const barChartData = [{ data: [4, 3, 5] }, { data: [1, 6, 3] }, { data: [2, 5, 6] }];
const EngagementBarChartTitle = 'Évolution des connexions';

const { user } = useContext(UserContext);
const statisticsSessions: SessionsStats | Record<string, never> = useStatisticsSessions(user?.villageId ?? 0);
const statisticsClassrooms = useStatisticsClassrooms(null, 'FR', null) as ClassroomsStats;
const [selectedCountry, setSelectedCountry] = useState<string>('');

// const countriesMap = mockClassroomsStats.map((country) => country.classroomCountryCode);
// const countries = [...new Set(countriesMap)]; // avoid duplicates
// const handleCountryChange = (country: string) => {
// setSelectedCountry(country);
const [selectedCountry, setSelectedCountry] = useState<string>('FR');
// const [selectedVillage, setSelectedVillage] = useState<string>('');
const statisticsClassrooms = useStatisticsClassrooms(null, selectedCountry, null) as ClassroomsStats;
const countriesMap = mockClassroomsStats.map((country) => country.classroomCountryCode);
const countries = [...new Set(countriesMap)]; // avoid duplicates
const handleCountryChange = (country: string) => {
setSelectedCountry(country);
};
// const handleVillageChange = (village: string) => {
// setSelectedVillage(village);
// };

const firstTable = {
Expand Down Expand Up @@ -69,12 +71,12 @@ const VillageStats = () => {
<div className={styles.smallFilter}>
<PhaseDropdown />
</div>
{/* <div className={styles.medFilter}>
<CountriesDropdown countries={countries} onCountryChange={handleCountryChange} label={'Tous les pays'} />
<div className={styles.medFilter}>
<Dropdown data={countries} onItemChange={handleCountryChange} label={'Tous les pays'} title="Pays" />
</div>
<div className={styles.medFilter}>
<CountriesDropdown countries={countries} onCountryChange={handleCountryChange} label={'Tous les pays'} />
</div> */}
<Dropdown data={countries} onItemChange={handleCountryChange} label={'Tous les villages'} title="Village" />
</div>
<div className={styles.medFilter} />
</div>
<CommentCard />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import { Typography } from '@mui/material';
import Paper from '@mui/material/Paper';
import Table from '@mui/material/Table';
Expand All @@ -9,8 +7,9 @@ import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import { Box } from '@mui/system';
import React from 'react';

function createData(classroom: string, vm: sting, prof: string, status: string) {
function createData(classroom: string, vm: string, prof: string, status: string) {
return { classroom, vm, prof, status };
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
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';
import * as React from 'react';

interface CountriesDropdownProps {
countries: string[];
onCountryChange: (country: string) => void;
interface DropdownProps {
data: string[];
onItemChange: (item: string) => void;
label: string;
title: string;
}

export default function CountriesDropdown({ countries, onCountryChange, label }: CountriesDropdownProps) {
const [country, setCountry] = React.useState('');
export default function Dropdown({ data, onItemChange, label, title }: DropdownProps) {
const [item, setItem] = React.useState('');

const handleChange = (event: SelectChangeEvent) => {
const selectedCountry = event.target.value as string;
setCountry(selectedCountry);
onCountryChange(selectedCountry);
const selectedItem = event.target.value as string;
setItem(selectedItem);
onItemChange(selectedItem);
};

return (
<Box>
<FormControl fullWidth size="small">
<InputLabel id="country-menu-select">Pays</InputLabel>
<Select labelId="country-menu-select" id="country-select" value={country} label="Pays" onChange={handleChange}>
<InputLabel id="country-menu-select">{title}</InputLabel>
<Select labelId="country-menu-select" id="country-select" value={item} label={title} onChange={handleChange}>
<MenuItem value="">{label}</MenuItem>
{countries.map((country) => (
<MenuItem key={country} value={country}>
{country}
{data.map((item) => (
<MenuItem key={item} value={item}>
{item}
</MenuItem>
))}
</Select>
Expand Down
4 changes: 2 additions & 2 deletions src/components/admin/dashboard-statistics/mocks/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ClassroomsStats, SessionsStats } from 'types/statistics.type';
import type { ClassroomStats, SessionsStats } from 'types/statistics.type';

export const mockClassroomsStats: ClassroomsStats[] = [
export const mockClassroomsStats: ClassroomStats[] = [
{
classroomId: 1,
classroomCountryCode: 'FR',
Expand Down
6 changes: 0 additions & 6 deletions types/statistics.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ export interface Phases {
phase: string;
}

interface Data {
name: string;
type6?: string;
type2?: string;
}

export interface ClassroomsStats {
data: ClassroomStats[];
phases: Phases[];
Expand Down

0 comments on commit 09b6c61

Please sign in to comment.