diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4757d05dc..d93705b5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: # [2] get node. - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '16.15.1' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8c0c93b85..b9dff9e97 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,7 +15,7 @@ jobs: # [2] get node. - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '16.15.1' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a510c680..064f55f2c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: # [2] get node. - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '16.15.1' @@ -33,7 +33,7 @@ jobs: # [2] get node. - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '16.15.1' @@ -53,7 +53,7 @@ jobs: # [2] get node. - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '16.15.1' diff --git a/src/components/KeepRatio.tsx b/src/components/KeepRatio.tsx index 30a14042c..236440930 100644 --- a/src/components/KeepRatio.tsx +++ b/src/components/KeepRatio.tsx @@ -3,6 +3,7 @@ import React from 'react'; interface KeepRatioProps { ratio: number; width?: string | number; + height?: string | number; maxWidth?: string | number; minHeight?: string | number; className?: string; @@ -10,6 +11,7 @@ interface KeepRatioProps { export const KeepRatio = ({ width = '100%', + height = '100%', maxWidth = '100%', minHeight = 0, ratio, @@ -20,7 +22,7 @@ export const KeepRatio = ({
-
+
{children}
diff --git a/src/components/WelcomeModal/FirstPhase.tsx b/src/components/WelcomeModal/FirstPhase.tsx index cfa3caa50..cb520e86e 100644 --- a/src/components/WelcomeModal/FirstPhase.tsx +++ b/src/components/WelcomeModal/FirstPhase.tsx @@ -272,9 +272,11 @@ export const FirstPhase = () => { { setNewUser((u) => ({ ...u, school })); }} @@ -282,9 +284,11 @@ export const FirstPhase = () => { { setNewUser((u) => ({ ...u, level })); }} @@ -292,10 +296,11 @@ export const FirstPhase = () => { { setNewUser((u) => ({ ...u, address })); }} @@ -303,10 +308,11 @@ export const FirstPhase = () => { { setNewUser((u) => ({ ...u, city })); }} @@ -314,10 +320,11 @@ export const FirstPhase = () => { { setNewUser((u) => ({ ...u, postalCode })); }} @@ -329,7 +336,7 @@ export const FirstPhase = () => { style={{ marginTop: '2rem' }} value={newUser.displayName || ''} defaultValue={'non renseigné'} - label="Nom affiché :" + label="Nom affiché : " placeholder={getUserDisplayName({ ...user, ...newUser, type: user?.type }, false)} isEditMode onChange={(displayName) => { diff --git a/src/components/accueil/NewHome.tsx b/src/components/accueil/NewHome.tsx index 0bfa829ea..a68f3fd46 100644 --- a/src/components/accueil/NewHome.tsx +++ b/src/components/accueil/NewHome.tsx @@ -26,24 +26,12 @@ export const NewHome = () => { return (
<> -
+

Vous êtes...

- -
+ +
{/* Block Teacher */}

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 = () => { ))} +
{ 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 = () => {