Skip to content

Commit

Permalink
fix: type event any to synthetic event
Browse files Browse the repository at this point in the history
feature: add filterdOptions to autocomplete component
  • Loading branch information
SimNed committed Sep 17, 2023
1 parent 4b63459 commit 06d6024
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/lancer-un-defi/linguistique/1.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 06d6024

Please sign in to comment.