Professeur des écoles
diff --git a/src/components/mon-compte/PanelInput.tsx b/src/components/mon-compte/PanelInput.tsx
index 954c4a290..e9be8eaa6 100644
--- a/src/components/mon-compte/PanelInput.tsx
+++ b/src/components/mon-compte/PanelInput.tsx
@@ -8,6 +8,7 @@ interface PanelInputProps {
defaultValue?: string;
label: string;
placeholder?: string;
+ isRequired?: boolean;
isEditMode?: boolean;
errorMsg?: string;
helperText?: string;
@@ -23,6 +24,7 @@ export const PanelInput = ({
defaultValue = '',
label,
placeholder = '',
+ isRequired = false,
isEditMode = true,
errorMsg,
helperText,
@@ -36,6 +38,7 @@ export const PanelInput = ({
{isEditMode ? (
{
setUserTypeFilter(e.target.value);
}, []);
+ const handleExportToCSV = () => {
+ if (filteredUsers.length < 1) return;
+
+ const datasToExport = filteredUsers.map((user) => {
+ return {
+ firstname: user.firstname,
+ lastname: user.lastname,
+ email: user.email,
+ school: user.school ? user.school : 'Non renseignee',
+ village: user.villageId ? villageMap[user.villageId]?.name : 'Non renseigne',
+ country: user.country ? user.country.name : 'Non renseigne',
+ };
+ });
+
+ const headers = ['Prenom', 'Nom', 'Email', 'Ecole', 'Village', 'Pays'];
+
+ let userLabel = 'liste-utilisateurs-';
+
+ for (const [key, value] of Object.entries(userTypeNames)) {
+ if (key === userTypeFilter) {
+ userLabel = 'liste-' + value.toLowerCase().replaceAll(' ', '-') + 's-';
+ }
+ }
+ const todayDate = new Date().toLocaleDateString('fr-FR').replaceAll('/', '-');
+ const fileName = userLabel + todayDate;
+
+ exportJsonToCsv(fileName, headers, datasToExport);
+ };
+
const actions = (id: number) => (
<>
@@ -157,6 +188,18 @@ const Users = () => {
))}
+ }
+ disabled={filteredUsers.length === 0}
+ >
+ Exporter en CSV
+
{
u.country
? {
id: u.id,
- pseudo: u.pseudo,
+ firstname: u.firstname,
+ lastname: u.lastname,
email: u.email,
school: u.school || Non renseignée,
country: `${countryToFlag(u.country?.isoCode)} ${u.country?.name}`,
@@ -177,7 +221,8 @@ const Users = () => {
}
: {
id: u.id,
- pseudo: u.pseudo,
+ firstname: u.firstname,
+ lastname: u.lastname,
email: u.email,
school: u.school || Non renseignée,
village: u.villageId ? (
@@ -189,7 +234,8 @@ const Users = () => {
},
)}
columns={[
- { key: 'pseudo', label: 'Pseudo', sortable: true },
+ { key: 'firstname', label: 'Prénom', sortable: true },
+ { key: 'lastname', label: 'Nom', sortable: true },
{ key: 'email', label: 'Email', sortable: true },
{ key: 'school', label: 'École', sortable: true },
{ key: 'village', label: 'Village', sortable: true },
diff --git a/src/pages/lancer-un-defi/linguistique/1.tsx b/src/pages/lancer-un-defi/linguistique/1.tsx
index a50cce0a8..8c1ced25e 100644
--- a/src/pages/lancer-un-defi/linguistique/1.tsx
+++ b/src/pages/lancer-un-defi/linguistique/1.tsx
@@ -1,8 +1,8 @@
import { useRouter } from 'next/router';
+import type { SyntheticEvent } from 'react';
import React from 'react';
-import type { SelectChangeEvent } from '@mui/material';
-import { ListSubheader, FormControlLabel, Grid, Radio, RadioGroup, Select, MenuItem, InputLabel, FormControl, Divider } from '@mui/material';
+import { TextField, Autocomplete, FormControlLabel, Grid, Radio, RadioGroup, FormControl } from '@mui/material';
import { isDefi } from 'src/activity-types/anyActivity';
import { DEFI, isLanguage, LANGUAGE_SCHOOL } from 'src/activity-types/defi.constants';
@@ -18,6 +18,7 @@ import { useActivity } from 'src/services/useActivity';
import { useLanguages } from 'src/services/useLanguages';
import { capitalize } from 'src/utils';
import { axiosRequest } from 'src/utils/axiosRequest';
+import { normalizeString } from 'src/utils/isNormalizedStringEqual';
import { ActivityStatus, ActivityType } from 'types/activity.type';
const getArticle = (language: string) => {
@@ -135,11 +136,14 @@ const DefiStep1 = () => {
router.push('/lancer-un-defi/linguistique/2');
};
- const handleLanguage = (event: SelectChangeEvent) => {
- const languageCode = (event.target as HTMLSelectElement).value;
- const language = languages.find((l) => l.alpha3_b.toLowerCase() === languageCode.slice(0, 2))?.french ?? '';
+ const handleLanguage = (_event: SyntheticEvent, languageCode: string) => {
+ const language =
+ languageCode.length === 2
+ ? languages.find((language) => languageCode === language.alpha2.toLowerCase())?.french
+ : languages.find((language) => languageCode === language.alpha3_b.toLowerCase())?.french;
updateActivity({ data: { ...data, languageCode, language } });
};
+
const setLanguageIndex = (event: React.ChangeEvent) => {
updateActivity({ data: { ...data, languageIndex: parseInt((event.target as HTMLInputElement).value, 10) } });
};
@@ -152,11 +156,6 @@ const DefiStep1 = () => {
);
}
- const LanguagesToRemove = mascotteLanguages.reduce((list, currentValue) => {
- list.push(currentValue.value);
- return list;
- }, new Array());
-
return (
@@ -182,28 +181,46 @@ const DefiStep1 = () => {
Vous pourrez ensuite choisir le thème de votre défi.
- Langues
-
+ {
+ if (!value) return;
+ const formatedValue = value.alpha2.length > 0 ? value.alpha2 : value.alpha3_b;
+ handleLanguage(e, formatedValue);
+ }}
+ options={languages.sort((a, b) => {
+ const aFormated = a.alpha2.length === 2 ? a.alpha2.toLowerCase() : a.alpha3_b.toLowerCase();
+ const bFormated = b.alpha2.length === 2 ? b.alpha2.toLowerCase() : b.alpha3_b.toLowerCase();
+
+ if (
+ mascotteLanguages.some((language) => aFormated === language.value.toLowerCase()) &&
+ !mascotteLanguages.some((language) => bFormated === language.value.toLowerCase())
+ )
+ return -1;
+ if (
+ !mascotteLanguages.some((language) => aFormated === language.value.toLowerCase()) &&
+ mascotteLanguages.some((language) => bFormated === language.value.toLowerCase())
+ )
+ return 1;
+
+ return aFormated.toLowerCase().localeCompare(bFormated.toLowerCase());
+ })}
+ filterOptions={(options, state) => {
+ return options.filter((option) =>
+ normalizeString(option.french).toLowerCase().startsWith(normalizeString(state.inputValue).toLowerCase()),
+ );
+ }}
+ groupBy={(option) => {
+ const optionFormated = option.alpha2.length === 2 ? option.alpha2 : option.alpha3_b;
+
+ return mascotteLanguages.find((language) => optionFormated === language.value.toLowerCase())
+ ? 'Langues parlées par votre mascotte'
+ : 'Autres langues';
+ }}
+ getOptionLabel={(option) => option.french}
+ sx={{ width: 300 }}
+ renderInput={(params) => }
+ />
diff --git a/src/pages/login.tsx b/src/pages/login.tsx
index 31d198599..38165cbd8 100644
--- a/src/pages/login.tsx
+++ b/src/pages/login.tsx
@@ -110,7 +110,7 @@ const SignInTeacher = () => {