From ceb3cb666f30bed0e02e0e79d11cd0ad06216c6b Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 8 Sep 2023 11:26:37 +0200 Subject: [PATCH 01/39] refactor login header style in .login__header and keepRatio first child in .login__container --- src/components/accueil/NewHome.tsx | 18 +++--------------- src/styles/login.scss | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 16 deletions(-) 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/styles/login.scss b/src/styles/login.scss index 911e10128..80708090d 100644 --- a/src/styles/login.scss +++ b/src/styles/login.scss @@ -1,12 +1,34 @@ @import 'variables'; +.login__header{ + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 10px; + background: white; + width: 95%; + height: 50px; + max-width: 1200px; + border-radius: 10px; + margin-bottom: 2rem; +} + .login__container { background-color: white; border-radius: 10px; - overflow: hidden; display: flex; + min-height: 100%; + + .text-center{ + display: flex; + justify-content: space-around; + align-items: center; + gap: 4rem; + padding: 2rem 0; + } } + + .login__panel { display: inline-flex; width: 50%; From 0ac2cb1e0bd936a8eac920173a01d5694956c46f Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 8 Sep 2023 11:27:49 +0200 Subject: [PATCH 02/39] add height props to {children} first parent in keepRatio component --- src/components/KeepRatio.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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}
From 55d0f7fb35f525df4e87a1de3427445e81507834 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 8 Sep 2023 11:28:42 +0200 Subject: [PATCH 03/39] add .flex-responsive for change flex-direction behaviour depands on media queries --- src/styles/base.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/styles/base.scss b/src/styles/base.scss index 61bb1f492..53e923813 100644 --- a/src/styles/base.scss +++ b/src/styles/base.scss @@ -135,6 +135,10 @@ main { padding-bottom: $verticalSpacing; } +.flex-responsive{ + flex-direction: row; +} + @include for-small-screen { .header__container { margin: math.div($verticalSpacing, 2) math.div($horizontalSpacing, 2) 0 math.div($horizontalSpacing, 2); @@ -178,6 +182,10 @@ main { .vertical-bottom-margin { margin-bottom: math.div($verticalSpacing, 2); } + + .flex-responsive{ + flex-direction: column; + } } @include for-laptop-screen-up { From c8375fb049eba98165270b8f6607df8a4377f044 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 8 Sep 2023 11:29:29 +0200 Subject: [PATCH 04/39] change height, minHeight, backgroudAttachment and overflow of .bg-gradiant --- src/styles/globals.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/styles/globals.scss b/src/styles/globals.scss index 4e3546a55..2599867dd 100644 --- a/src/styles/globals.scss +++ b/src/styles/globals.scss @@ -150,10 +150,12 @@ a.text--success:hover { // misc .bg-gradiant { width: 100vw; - height: 100vh; + min-height: 100vh; background: rgb(224, 195, 252); background: -o-linear-gradient(315deg, rgba(224, 195, 252, 1) 0%, rgba(142, 197, 252, 1) 100%); background: linear-gradient(135deg, rgba(224, 195, 252, 1) 0%, rgba(142, 197, 252, 1) 100%); + background-attachment: fixed; + overflow: auto; display: flex; justify-content: center; align-items: center; From 05eb7257de3cfde492274aa33271e7cbdea7f9a2 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 8 Sep 2023 11:45:10 +0200 Subject: [PATCH 05/39] fix login style bug by nested class in .login__container .text-center by .flex-responsive --- src/styles/login.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/styles/login.scss b/src/styles/login.scss index 80708090d..85bd0dd31 100644 --- a/src/styles/login.scss +++ b/src/styles/login.scss @@ -17,8 +17,8 @@ border-radius: 10px; display: flex; min-height: 100%; - - .text-center{ + + .flex-responsive{ display: flex; justify-content: space-around; align-items: center; From 2664d361d34c1e2573e56c95cec5dc435126e90c Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Thu, 14 Sep 2023 11:43:20 +0200 Subject: [PATCH 06/39] feat: allow json to be converted and export in csv --- src/utils/csv-export.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/utils/csv-export.ts diff --git a/src/utils/csv-export.ts b/src/utils/csv-export.ts new file mode 100644 index 000000000..a393f4e05 --- /dev/null +++ b/src/utils/csv-export.ts @@ -0,0 +1,28 @@ +export const exportJsonToCsv = (filename: string, headers: string[], datas: Record[]) => { + const headersToString = headers.toString(); + + const datasToString = datas.map((data) => { + return Object.values(data).toString(); + }); + + const datasToCsvFormat = [headersToString, ...datasToString].join('\n'); + + downloadToCsv(filename, datasToCsvFormat); +}; + +const downloadToCsv = (fileName: string, datas: string) => { + const blob = new Blob([datas], { type: 'application/csv' }); + const url = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.download = fileName + '.csv'; + a.href = url; + a.style.display = 'none'; + + document.body.appendChild(a); + + a.click(); + + a.remove(); + URL.revokeObjectURL(url); +}; From 51ec47cc5217f7cca9f7ada854aeceb431d2ab97 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Thu, 14 Sep 2023 16:22:48 +0200 Subject: [PATCH 07/39] fix: delete all comma in headers and datas to avoid csv join conflicts --- src/utils/csv-export.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils/csv-export.ts b/src/utils/csv-export.ts index a393f4e05..5dca89119 100644 --- a/src/utils/csv-export.ts +++ b/src/utils/csv-export.ts @@ -1,8 +1,16 @@ export const exportJsonToCsv = (filename: string, headers: string[], datas: Record[]) => { - const headersToString = headers.toString(); + const escapedHeaders = headers.map((header) => { + return header.replaceAll(',', ''); + }); + + const headersToString = escapedHeaders.toString(); const datasToString = datas.map((data) => { - return Object.values(data).toString(); + const escapedData = Object.values(data).map((value) => { + return typeof value === 'string' ? value.replaceAll(',', '') : value; + }); + + return escapedData.toString(); }); const datasToCsvFormat = [headersToString, ...datasToString].join('\n'); From 835b156c901b98a276da4afa8664eace584553fd Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Thu, 14 Sep 2023 16:54:01 +0200 Subject: [PATCH 08/39] feature: add exportToCsv button --- src/pages/admin/users/index.tsx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/pages/admin/users/index.tsx b/src/pages/admin/users/index.tsx index 1af16c3f8..d1b8970f8 100644 --- a/src/pages/admin/users/index.tsx +++ b/src/pages/admin/users/index.tsx @@ -4,6 +4,7 @@ import React, { useCallback, useMemo, useState } from 'react'; import AddCircleIcon from '@mui/icons-material/AddCircle'; import DeleteIcon from '@mui/icons-material/Delete'; +import DownloadIcon from '@mui/icons-material/Download'; import EditIcon from '@mui/icons-material/Edit'; import type { SelectChangeEvent } from '@mui/material'; import { FormControl, InputLabel, MenuItem, Select, TextField, Typography } from '@mui/material'; @@ -22,6 +23,7 @@ import { useUsers, useUserRequests } from 'src/services/useUsers'; import { useVillages } from 'src/services/useVillages'; import { defaultContainedButtonStyle } from 'src/styles/variables.const'; import { countryToFlag } from 'src/utils'; +import { exportJsonToCsv } from 'src/utils/csv-export'; import { userTypeNames } from 'types/user.type'; import type { Village } from 'types/village.type'; @@ -64,6 +66,26 @@ const Users = () => { setUserTypeFilter(e.target.value); }, []); + const handleExportToCSV = () => { + if (filteredUsers.length < 1) return; + + const datasToExport = filteredUsers.map((user) => { + return { + pseudo: user.pseudo, + email: user.email, + school: user.school ? user.school : 'Non renseignée', + village: user.villageId ? villageMap[user.villageId]?.name : 'Non renseigné', + country: user.country ? user.country.name : 'Non renseigné', + }; + }); + + // Récupérer le nom de l'utilisateur avec le type : const userTypeLabel = userTypeFilter.length > 1 ? userTypeNames[???] : 'Utilisateur'; + const todayDate = new Date().toLocaleDateString('fr-FR').replaceAll('/', '-'); + const fileName = todayDate; + + exportJsonToCsv(fileName, ['Pseudo', 'Email', 'Ecole', 'Village', 'Pays'], datasToExport); + }; + const actions = (id: number) => ( <> @@ -157,6 +179,17 @@ const Users = () => { ))} +
Date: Thu, 14 Sep 2023 16:55:45 +0200 Subject: [PATCH 09/39] fix: add 'utilisateurs' in csv file name --- src/pages/admin/users/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/admin/users/index.tsx b/src/pages/admin/users/index.tsx index d1b8970f8..737399ff8 100644 --- a/src/pages/admin/users/index.tsx +++ b/src/pages/admin/users/index.tsx @@ -81,7 +81,7 @@ const Users = () => { // Récupérer le nom de l'utilisateur avec le type : const userTypeLabel = userTypeFilter.length > 1 ? userTypeNames[???] : 'Utilisateur'; const todayDate = new Date().toLocaleDateString('fr-FR').replaceAll('/', '-'); - const fileName = todayDate; + const fileName = 'utilisateurs-' + todayDate; exportJsonToCsv(fileName, ['Pseudo', 'Email', 'Ecole', 'Village', 'Pays'], datasToExport); }; From ec5f6c00bfd68fd817aa06aa18603d34ed65b4c8 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 15 Sep 2023 09:41:49 +0200 Subject: [PATCH 10/39] fix: disable export csv button when there is no filtered users --- src/pages/admin/users/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/admin/users/index.tsx b/src/pages/admin/users/index.tsx index 737399ff8..3a25dd0cf 100644 --- a/src/pages/admin/users/index.tsx +++ b/src/pages/admin/users/index.tsx @@ -187,6 +187,7 @@ const Users = () => { variant="contained" style={{ flexShrink: 0, marginLeft: '1rem' }} startIcon={} + disabled={filteredUsers.length === 0} > Exporter en CSV From d92db77893e4a928aea13ce9804438576c308482 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 15 Sep 2023 09:57:40 +0200 Subject: [PATCH 11/39] fix: escaping specials characters instead of delete comma in exportToCsv function --- src/utils/csv-export.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/csv-export.ts b/src/utils/csv-export.ts index 5dca89119..65d1e1728 100644 --- a/src/utils/csv-export.ts +++ b/src/utils/csv-export.ts @@ -1,13 +1,13 @@ export const exportJsonToCsv = (filename: string, headers: string[], datas: Record[]) => { const escapedHeaders = headers.map((header) => { - return header.replaceAll(',', ''); + return `"${header}"`; }); const headersToString = escapedHeaders.toString(); const datasToString = datas.map((data) => { const escapedData = Object.values(data).map((value) => { - return typeof value === 'string' ? value.replaceAll(',', '') : value; + return typeof value === 'string' ? `"${value}"` : value; }); return escapedData.toString(); From ac6f76a3d34a336b48d8fa08ff40998036bc31b4 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 15 Sep 2023 11:07:07 +0200 Subject: [PATCH 12/39] feature: add dynamic filename to users csv file --- src/pages/admin/users/index.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/admin/users/index.tsx b/src/pages/admin/users/index.tsx index 3a25dd0cf..0a7a0f425 100644 --- a/src/pages/admin/users/index.tsx +++ b/src/pages/admin/users/index.tsx @@ -79,11 +79,19 @@ const Users = () => { }; }); - // Récupérer le nom de l'utilisateur avec le type : const userTypeLabel = userTypeFilter.length > 1 ? userTypeNames[???] : 'Utilisateur'; + const headers = ['Pseu,d""o', '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 = 'utilisateurs-' + todayDate; + const fileName = userLabel + todayDate; - exportJsonToCsv(fileName, ['Pseudo', 'Email', 'Ecole', 'Village', 'Pays'], datasToExport); + exportJsonToCsv(fileName, headers, datasToExport); }; const actions = (id: number) => ( From e03b27f777268b1c76df5858432babc71cfdc225 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Fri, 15 Sep 2023 11:08:04 +0200 Subject: [PATCH 13/39] fix: update csv header value --- src/pages/admin/users/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/admin/users/index.tsx b/src/pages/admin/users/index.tsx index 0a7a0f425..3a20599e5 100644 --- a/src/pages/admin/users/index.tsx +++ b/src/pages/admin/users/index.tsx @@ -79,7 +79,7 @@ const Users = () => { }; }); - const headers = ['Pseu,d""o', 'Email', 'Ecole', 'Village', 'Pays']; + const headers = ['Pseudo', 'Email', 'Ecole', 'Village', 'Pays']; let userLabel = 'liste-utilisateurs-'; From 00f5e1e200a66c13a0d996aaa59e9d3e7a5e6ab7 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Sat, 16 Sep 2023 10:33:11 +0200 Subject: [PATCH 14/39] fix: modify input and subheader components to autocomplete component --- src/pages/lancer-un-defi/linguistique/1.tsx | 69 +++++++++++++-------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/src/pages/lancer-un-defi/linguistique/1.tsx b/src/pages/lancer-un-defi/linguistique/1.tsx index a50cce0a8..4b177b017 100644 --- a/src/pages/lancer-un-defi/linguistique/1.tsx +++ b/src/pages/lancer-un-defi/linguistique/1.tsx @@ -1,8 +1,7 @@ import { useRouter } from 'next/router'; 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'; @@ -135,11 +134,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: any, 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) } }); }; @@ -182,28 +184,41 @@ 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()); + })} + 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) => } + /> From d2218c369e29d478ba0efb4e281a33b6f67e9c73 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Sat, 16 Sep 2023 10:34:23 +0200 Subject: [PATCH 15/39] fix: remove unused LanguagesToRemove function --- src/pages/lancer-un-defi/linguistique/1.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pages/lancer-un-defi/linguistique/1.tsx b/src/pages/lancer-un-defi/linguistique/1.tsx index 4b177b017..bca2f6c5e 100644 --- a/src/pages/lancer-un-defi/linguistique/1.tsx +++ b/src/pages/lancer-un-defi/linguistique/1.tsx @@ -154,11 +154,6 @@ const DefiStep1 = () => { ); } - const LanguagesToRemove = mascotteLanguages.reduce((list, currentValue) => { - list.push(currentValue.value); - return list; - }, new Array()); - return (
From 6d22cd346dcf15b72c1674f2c3b2a9edd316bdc3 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Sat, 16 Sep 2023 11:56:34 +0200 Subject: [PATCH 16/39] feature: add isRequired field on PanelInput --- src/components/mon-compte/PanelInput.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/mon-compte/PanelInput.tsx b/src/components/mon-compte/PanelInput.tsx index 954c4a290..3a61ef1b9 100644 --- a/src/components/mon-compte/PanelInput.tsx +++ b/src/components/mon-compte/PanelInput.tsx @@ -9,6 +9,7 @@ interface PanelInputProps { label: string; placeholder?: string; isEditMode?: boolean; + isRequired?: boolean; errorMsg?: string; helperText?: string; hasError?: boolean; @@ -24,6 +25,7 @@ export const PanelInput = ({ label, placeholder = '', isEditMode = true, + isRequired = false, errorMsg, helperText, type = 'text', @@ -36,6 +38,7 @@ export const PanelInput = ({
{isEditMode ? ( Date: Sat, 16 Sep 2023 11:57:05 +0200 Subject: [PATCH 17/39] fix: update PanelInputs as isRequired --- src/components/WelcomeModal/FirstPhase.tsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/WelcomeModal/FirstPhase.tsx b/src/components/WelcomeModal/FirstPhase.tsx index cfa3caa50..eb0abecd0 100644 --- a/src/components/WelcomeModal/FirstPhase.tsx +++ b/src/components/WelcomeModal/FirstPhase.tsx @@ -96,6 +96,8 @@ export const FirstPhase = () => { setIsLoading(false); }; + const label = **; + const sendError = (error: 'village' | 'country') => async () => { // do not ask twice if (updateAsked[error]) { @@ -272,9 +274,10 @@ export const FirstPhase = () => { { setNewUser((u) => ({ ...u, school })); }} @@ -282,9 +285,10 @@ 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,9 +336,10 @@ 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 + isRequired onChange={(displayName) => { setNewUser((u) => ({ ...u, displayName })); }} From 4b634598863ae6b3f9039451c87e66d28e9047f2 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Sun, 17 Sep 2023 11:52:16 +0200 Subject: [PATCH 18/39] feature: add normalizeString func in isNormalizedStringEqual utils --- src/utils/isNormalizedStringEqual.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/isNormalizedStringEqual.ts b/src/utils/isNormalizedStringEqual.ts index cd63e4b0f..10063aac9 100644 --- a/src/utils/isNormalizedStringEqual.ts +++ b/src/utils/isNormalizedStringEqual.ts @@ -1,8 +1,16 @@ // Normalise les chaînes de caractères et les compare pour retourner un boolean +export const normalizeString = (data: string): string => { + return data.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); +}; + export const isNormalizedStringEqual = (str1: string, str2: string): boolean => { const strNorm1 = str1.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); const strNorm2 = str2.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); return strNorm1.toLocaleLowerCase() === strNorm2.toLocaleLowerCase(); }; + +// export const isNormalizedStringEqual = (str1: string, str2: string): boolean => { +// return normalizeString(str1).toLocaleLowerCase() === normalizeString(str2).toLocaleLowerCase(); +// }; From 06d6024b4b4b6886acc45f95e17dbfcd1c1bcc6b Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Sun, 17 Sep 2023 11:53:11 +0200 Subject: [PATCH 19/39] fix: type event any to synthetic event feature: add filterdOptions to autocomplete component --- src/pages/lancer-un-defi/linguistique/1.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/lancer-un-defi/linguistique/1.tsx b/src/pages/lancer-un-defi/linguistique/1.tsx index bca2f6c5e..8c1ced25e 100644 --- a/src/pages/lancer-un-defi/linguistique/1.tsx +++ b/src/pages/lancer-un-defi/linguistique/1.tsx @@ -1,4 +1,5 @@ import { useRouter } from 'next/router'; +import type { SyntheticEvent } from 'react'; import React from 'react'; import { TextField, Autocomplete, FormControlLabel, Grid, Radio, RadioGroup, FormControl } from '@mui/material'; @@ -17,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) => { @@ -134,7 +136,7 @@ const DefiStep1 = () => { router.push('/lancer-un-defi/linguistique/2'); }; - const handleLanguage = (_event: any, languageCode: string) => { + const handleLanguage = (_event: SyntheticEvent, languageCode: string) => { const language = languageCode.length === 2 ? languages.find((language) => languageCode === language.alpha2.toLowerCase())?.french @@ -203,6 +205,11 @@ const DefiStep1 = () => { 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; From c476f5a9e6f5d341ee3b47e793adc5e369b806d4 Mon Sep 17 00:00:00 2001 From: charlinedev Date: Wed, 27 Sep 2023 10:45:19 +0200 Subject: [PATCH 20/39] add hasError --- src/components/WelcomeModal/FirstPhase.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/WelcomeModal/FirstPhase.tsx b/src/components/WelcomeModal/FirstPhase.tsx index eb0abecd0..f4947af9a 100644 --- a/src/components/WelcomeModal/FirstPhase.tsx +++ b/src/components/WelcomeModal/FirstPhase.tsx @@ -276,6 +276,7 @@ export const FirstPhase = () => { defaultValue={'non renseignée'} label="École : " placeholder="Nom de votre école : " + hasError={!newUser.school} isEditMode isRequired onChange={(school) => { @@ -287,6 +288,7 @@ export const FirstPhase = () => { defaultValue={'non renseigné'} label="Niveau de la classe : " placeholder="Niveau de votre classe" + hasError={!newUser.level} isEditMode isRequired onChange={(level) => { From 9bd4a808a719b42c5ca12e44ae9ab1a99589ae26 Mon Sep 17 00:00:00 2001 From: charlinedev Date: Wed, 27 Sep 2023 10:56:14 +0200 Subject: [PATCH 21/39] Change pseudo to firstName lastName --- src/pages/admin/users/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/admin/users/index.tsx b/src/pages/admin/users/index.tsx index 3a20599e5..854ea9c25 100644 --- a/src/pages/admin/users/index.tsx +++ b/src/pages/admin/users/index.tsx @@ -206,7 +206,8 @@ 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}`, @@ -219,7 +220,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 ? ( @@ -231,7 +233,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 }, From a8fcec2bcbf9dbd8cd14c1c487fc811288481a83 Mon Sep 17 00:00:00 2001 From: charlinedev Date: Wed, 27 Sep 2023 12:03:27 +0200 Subject: [PATCH 22/39] lastModif --- src/pages/admin/users/index.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/admin/users/index.tsx b/src/pages/admin/users/index.tsx index 854ea9c25..74736b6a3 100644 --- a/src/pages/admin/users/index.tsx +++ b/src/pages/admin/users/index.tsx @@ -71,15 +71,16 @@ const Users = () => { const datasToExport = filteredUsers.map((user) => { return { - pseudo: user.pseudo, + firstname: user.firstname, + lastname: user.lastname, email: user.email, - school: user.school ? user.school : 'Non renseignée', - village: user.villageId ? villageMap[user.villageId]?.name : 'Non renseigné', - country: user.country ? user.country.name : 'Non renseigné', + 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 = ['Pseudo', 'Email', 'Ecole', 'Village', 'Pays']; + const headers = ['Prenom', 'Nom', 'Email', 'Ecole', 'Village', 'Pays']; let userLabel = 'liste-utilisateurs-'; From ea5a63549a4815b9c68c80302ea3bc0cf3a96a6d Mon Sep 17 00:00:00 2001 From: charlinedev Date: Thu, 28 Sep 2023 14:23:38 +0200 Subject: [PATCH 23/39] comment label --- src/components/WelcomeModal/FirstPhase.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/WelcomeModal/FirstPhase.tsx b/src/components/WelcomeModal/FirstPhase.tsx index f4947af9a..7bc575316 100644 --- a/src/components/WelcomeModal/FirstPhase.tsx +++ b/src/components/WelcomeModal/FirstPhase.tsx @@ -96,7 +96,7 @@ export const FirstPhase = () => { setIsLoading(false); }; - const label = **; + //const label = **; const sendError = (error: 'village' | 'country') => async () => { // do not ask twice From cad2d8c6f3bef2276f4e51a8123ed043c15a72cd Mon Sep 17 00:00:00 2001 From: charlinedev Date: Thu, 28 Sep 2023 15:48:54 +0200 Subject: [PATCH 24/39] Remove label --- src/components/WelcomeModal/FirstPhase.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/WelcomeModal/FirstPhase.tsx b/src/components/WelcomeModal/FirstPhase.tsx index 7bc575316..7267e2857 100644 --- a/src/components/WelcomeModal/FirstPhase.tsx +++ b/src/components/WelcomeModal/FirstPhase.tsx @@ -96,8 +96,6 @@ export const FirstPhase = () => { setIsLoading(false); }; - //const label = **; - const sendError = (error: 'village' | 'country') => async () => { // do not ask twice if (updateAsked[error]) { From 5cd2e1f79eb30cf0c3884043316a0e0b5e727804 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Mon, 2 Oct 2023 11:42:46 +0200 Subject: [PATCH 25/39] =?UTF-8?q?fix:=20remove=20isRequired=20field=20to?= =?UTF-8?q?=20input=20"Nom=20affich=C3=A9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/WelcomeModal/FirstPhase.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/WelcomeModal/FirstPhase.tsx b/src/components/WelcomeModal/FirstPhase.tsx index f4947af9a..7356e06e3 100644 --- a/src/components/WelcomeModal/FirstPhase.tsx +++ b/src/components/WelcomeModal/FirstPhase.tsx @@ -341,7 +341,6 @@ export const FirstPhase = () => { label="Nom affiché : " placeholder={getUserDisplayName({ ...user, ...newUser, type: user?.type }, false)} isEditMode - isRequired onChange={(displayName) => { setNewUser((u) => ({ ...u, displayName })); }} From d4030ee25212fe1e1dbe36ead39b3262f7e6fafc Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Tue, 3 Oct 2023 14:49:20 +0200 Subject: [PATCH 26/39] fix: change login video src with new video src --- src/pages/login.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = () => {