From d0c4e69a8afae8506067e701944a3744d5babe08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Mon, 28 Mar 2022 14:57:11 +0200 Subject: [PATCH] Autofix new eslint rules --- exoneration-covid/index.d.ts | 1 + modele-social/index.d.ts | 1 + site/scripts/search/update-data.ts | 4 +++- site/source/ATInternetTracking/Tracker.ts | 2 ++ site/source/ATInternetTracking/index.ts | 6 +++++ site/source/App.tsx | 3 +++ site/source/actions/companyStatusActions.ts | 2 ++ site/source/api/commune.ts | 2 ++ site/source/api/fabrique-social.ts | 1 + site/source/api/sirene.ts | 2 ++ site/source/components/Banner.tsx | 1 + site/source/components/BarChart.tsx | 1 + site/source/components/EngineValue.tsx | 7 ++++++ site/source/components/Feedback/index.tsx | 1 + site/source/components/LegalNotice.tsx | 1 + site/source/components/PaySlip.tsx | 5 +++++ site/source/components/PaySlipSections.tsx | 4 +++- site/source/components/PeriodSwitch.tsx | 1 + site/source/components/RuleLink.tsx | 1 + .../ShareSimulationPopup.tsx | 1 + .../ShareSimulationBanner/index.tsx | 1 + .../components/Simulation/Questions.tsx | 1 + .../components/Simulation/SimulationGoal.tsx | 1 + .../components/Simulation/SimulationGoals.tsx | 1 + site/source/components/Simulation/index.tsx | 1 + site/source/components/StackedBarChart.tsx | 5 +++++ .../components/company/SearchDetails.tsx | 1 + .../components/conversation/AnswerList.tsx | 1 + .../components/conversation/ChoicesInput.tsx | 1 + .../components/conversation/DateInput.tsx | 6 ++++- .../components/conversation/Explicable.tsx | 8 +++++-- .../conversation/InputSuggestions.tsx | 8 +++++-- .../components/conversation/NumberInput.tsx | 3 +++ .../components/conversation/RuleInput.tsx | 17 +++++++++----- .../components/conversation/TextInput.tsx | 1 + .../conversation/select/SelectCommune.tsx | 3 +++ .../select/SelectEuropeCountry.tsx | 1 + .../select/SelectPaysDétachement.tsx | 2 ++ .../components/layout/Footer/Contact.tsx | 1 + site/source/components/layout/Header.tsx | 1 + site/source/components/layout/NewsBanner.tsx | 1 + .../search/RulesInfiniteHits/index.tsx | 1 + site/source/components/search/SearchBox.tsx | 1 + .../search/SearchRulesAndSimulators.tsx | 1 + .../components/search/SimulatorHits.tsx | 1 + .../IndépendantCotisationsForfaitaires.tsx | 1 + .../IndépendantCotisationsRégularisation.tsx | 1 + .../IndépendantExplanation.tsx | 1 + .../InstitutionsPartenaires.tsx | 5 +++++ .../components/ui/AnimatedTargetValue.tsx | 2 ++ site/source/components/ui/Checklist/index.tsx | 2 ++ site/source/components/ui/animate.tsx | 3 +++ site/source/components/utils/BrowserOnly.tsx | 1 + .../utils/DisableAnimationContext.tsx | 3 +++ site/source/components/utils/DisableScroll.ts | 2 ++ site/source/components/utils/Emoji.tsx | 2 ++ .../source/components/utils/EngineContext.tsx | 4 ++++ site/source/components/utils/Meta.tsx | 1 + site/source/components/utils/Scroll.tsx | 1 + .../components/utils/embeddedContext.tsx | 1 + site/source/components/utils/index.tsx | 1 + site/source/components/utils/markdown.tsx | 1 + site/source/components/utils/persistState.ts | 2 ++ .../utils/useDisplayOnIntersecting.ts | 2 ++ .../components/utils/useInitialRender.tsx | 1 + .../components/utils/useNextQuestion.tsx | 5 +++++ .../components/utils/useSearchParams.ts | 1 + .../utils/useSearchParamsSimulationSharing.ts | 7 +++++- site/source/design-system/Popover.tsx | 1 + site/source/design-system/buttons/Button.tsx | 12 +++++++--- site/source/design-system/card/Card.tsx | 1 + site/source/design-system/field/Checkbox.tsx | 1 + .../design-system/field/NumberField.tsx | 5 +++++ .../design-system/field/Radio/Radio.tsx | 1 + .../design-system/field/Select/ListBox.tsx | 2 ++ .../design-system/field/Select/index.tsx | 2 ++ .../source/design-system/layout/Container.tsx | 1 + site/source/design-system/message/index.tsx | 3 +++ .../design-system/typography/heading.tsx | 22 ++++++++++++++----- site/source/design-system/typography/link.tsx | 2 ++ site/source/hexToHSL.ts | 1 + site/source/hooks/useDebounce.ts | 1 + site/source/locales/translateRules.ts | 2 ++ site/source/pages/Budget/Budget.tsx | 4 ++++ site/source/pages/Creer/CreationChecklist.tsx | 5 ++++- .../Creer/GuideStatut/AutoEntrepreneur.tsx | 1 + .../Creer/GuideStatut/DirectorStatus.tsx | 1 + .../Creer/GuideStatut/MinorityDirector.tsx | 1 + .../Creer/GuideStatut/NumberOfAssociate.tsx | 1 + .../Creer/GuideStatut/PickLegalStatus.tsx | 2 ++ .../Creer/GuideStatut/PreviousAnswers.tsx | 1 + .../Creer/GuideStatut/SoleProprietorship.tsx | 1 + site/source/pages/Creer/GuideStatut/index.tsx | 1 + site/source/pages/Creer/Home.tsx | 1 + site/source/pages/Creer/StatutDescription.tsx | 1 + site/source/pages/Creer/index.tsx | 1 + site/source/pages/Dev/IntegrationTest.tsx | 2 ++ site/source/pages/Dev/Sitemap.tsx | 1 + site/source/pages/Documentation.tsx | 3 +++ .../AideDéclarationIndépendant/Fields.tsx | 4 ++++ .../PreviousVersion.tsx | 2 ++ .../RésultatSimple.tsx | 2 ++ .../RésultatsParFormulaire.tsx | 2 ++ .../AideDéclarationIndépendant/index.tsx | 1 + .../pages/Gerer/DemandeMobilite/EndBlock.tsx | 2 ++ .../pages/Gerer/DemandeMobilite/FieldsPDF.tsx | 2 ++ .../pages/Gerer/DemandeMobilite/index.tsx | 2 ++ site/source/pages/Gerer/Embaucher.tsx | 1 + site/source/pages/Gerer/Home.tsx | 5 +++++ site/source/pages/Gerer/SécuritéSociale.tsx | 1 + .../pages/Gerer/cards/AutoEntrepeneurCard.tsx | 2 ++ .../cards/DeclarationIndependantsCard.tsx | 1 + .../pages/Gerer/cards/DemarcheEmbauche.tsx | 1 + .../source/pages/Gerer/cards/MobiliteCard.tsx | 1 + .../pages/Gerer/cards/MontantEmbauche.tsx | 1 + site/source/pages/Gerer/index.tsx | 1 + site/source/pages/Landing/SearchOrCreate.tsx | 2 ++ site/source/pages/Nouveautes/Nouveautes.tsx | 1 + .../pages/Simulateurs/AidesEmbauche/index.tsx | 1 + .../pages/Simulateurs/ArtisteAuteur.tsx | 1 + .../pages/Simulateurs/ChômagePartiel.tsx | 4 ++++ site/source/pages/Simulateurs/Dividendes.tsx | 1 + .../ActiviteCard/index.tsx | 1 + .../ActivitésSelection.tsx | 2 ++ .../EconomieCollaborative/Exonérations.tsx | 5 ++++- .../EconomieCollaborative/NextButton.tsx | 1 + .../EconomieCollaborative/VotreSituation.tsx | 1 + .../EconomieCollaborative/activitésData.ts | 1 + .../EconomieCollaborative/index.tsx | 1 + .../EconomieCollaborative/reducer.ts | 5 +++++ site/source/pages/Simulateurs/Home.tsx | 1 + .../source/pages/Simulateurs/ImpôtSociété.tsx | 1 + site/source/pages/Simulateurs/PAMCHome.tsx | 1 + site/source/pages/Simulateurs/Salarié.tsx | 3 +++ .../cards/IframeIntegrationCard.tsx | 1 + .../cards/SimulatorRessourceCard.tsx | 4 +++- site/source/pages/Simulateurs/index.tsx | 1 + site/source/pages/Stats/Chart.tsx | 3 +++ .../pages/Stats/DemandesUtilisateurs.tsx | 1 + site/source/pages/Stats/GlobalStats.tsx | 2 ++ site/source/pages/Stats/SatisfactionChart.tsx | 4 ++++ site/source/pages/Stats/Stats.tsx | 5 +++++ site/source/pages/integration/Iframe.tsx | 2 ++ site/source/pages/integration/index.tsx | 1 + .../reducers/choixStatutJuridiqueReducer.ts | 3 +++ .../reducers/companySituationReducer.ts | 2 ++ site/source/reducers/rootReducer.ts | 9 +++++++- .../selectors/companyStatusSelectors.ts | 4 ++++ site/source/selectors/simulationSelectors.ts | 2 ++ site/source/sitePaths.ts | 2 ++ .../storage/persistChoixStatutJuridique.ts | 1 + .../source/storage/persistCompanySituation.ts | 1 + site/source/storage/persistSimulation.ts | 9 ++++++-- site/source/storage/safeLocalStorage.ts | 3 +++ site/source/utils.ts | 4 ++++ 155 files changed, 351 insertions(+), 27 deletions(-) diff --git a/exoneration-covid/index.d.ts b/exoneration-covid/index.d.ts index 8cb6cf61e..5520252a5 100644 --- a/exoneration-covid/index.d.ts +++ b/exoneration-covid/index.d.ts @@ -6,4 +6,5 @@ import { Names } from './dist/names' export type DottedName = Names declare let rules: Record + export default rules diff --git a/modele-social/index.d.ts b/modele-social/index.d.ts index 8cb6cf61e..5520252a5 100644 --- a/modele-social/index.d.ts +++ b/modele-social/index.d.ts @@ -6,4 +6,5 @@ import { Names } from './dist/names' export type DottedName = Names declare let rules: Record + export default rules diff --git a/site/scripts/search/update-data.ts b/site/scripts/search/update-data.ts index 56affc87d..c403fe92f 100644 --- a/site/scripts/search/update-data.ts +++ b/site/scripts/search/update-data.ts @@ -25,7 +25,9 @@ const falsy = (value: T | false): value is T => Boolean(value) const formatRulesToAlgolia = (rules: ParsedRules) => Object.entries(rules) .map(([n, rule]) => { - if (!rule) return false + if (!rule) { + return false + } const path = n.split(' . ') const { title, diff --git a/site/source/ATInternetTracking/Tracker.ts b/site/source/ATInternetTracking/Tracker.ts index 952579b8c..ae40834cf 100644 --- a/site/source/ATInternetTracking/Tracker.ts +++ b/site/source/ATInternetTracking/Tracker.ts @@ -85,6 +85,7 @@ export function createTracker(siteId?: string, doNotTrack = false) { super.dispatch() } } + return Tag } @@ -116,6 +117,7 @@ export class Log implements ATTracker { }, getVisitorMode() { console.debug('ATTracker::privacy.getVisitorMode') + return { name: 'exempt' } }, } diff --git a/site/source/ATInternetTracking/index.ts b/site/source/ATInternetTracking/index.ts index 75609b1dc..da78b6c0d 100644 --- a/site/source/ATInternetTracking/index.ts +++ b/site/source/ATInternetTracking/index.ts @@ -14,6 +14,7 @@ export function toAtString(string: string): string { string = string.replace(/[\307\347]/g, 'c') string = string.replace(/[\321\361]/g, 'n') string = string.replace(/[^\w]/gi, '_') + return string } @@ -31,6 +32,7 @@ let chapters: { chapter2?: string chapter3?: string } = {} + export function TrackChapter(props: { chapter1?: Chapter1 chapter2?: string @@ -38,14 +40,17 @@ export function TrackChapter(props: { }) { if (props.chapter1) { chapters = { chapter2: '', chapter3: '', ...props } + return null } if (props.chapter2) { chapters = { ...chapters, chapter3: '', ...props } + return null } chapters = { ...chapters, ...props } + return null } @@ -73,5 +78,6 @@ export function TrackPage(props: { propsFormatted.chapter2, propsFormatted.chapter3, ]) + return null } diff --git a/site/source/App.tsx b/site/source/App.tsx index 386cbaf48..2b9b0097f 100644 --- a/site/source/App.tsx +++ b/site/source/App.tsx @@ -70,6 +70,7 @@ export default function Root({ // eslint-disable-next-line react-hooks/exhaustive-deps [rules] ) + return ( { }), [configSituation, simulatorSituation, companySituation] ) + return ( @@ -130,6 +132,7 @@ const App = () => { const { t } = useTranslation() const sitePaths = useContext(SitePathsContext) const isEmbedded = useIsEmbedded() + return ( {!isEmbedded &&
} diff --git a/site/source/actions/companyStatusActions.ts b/site/source/actions/companyStatusActions.ts index ce0cdeb77..e6028f6d8 100644 --- a/site/source/actions/companyStatusActions.ts +++ b/site/source/actions/companyStatusActions.ts @@ -28,6 +28,7 @@ export const useDispatchAndGoToNextQuestion = () => { history.push(nextQuestion) } }, [dispatched]) + return (action: Action) => { dispatch(action) setDispatched(true) @@ -76,6 +77,7 @@ export const resetCompanyStatusChoice = ( export const useSetEntreprise = () => { const dispatch = useDispatch() + return (entreprise: FabriqueSocialEntreprise) => { if (entreprise === null) { return diff --git a/site/source/api/commune.ts b/site/source/api/commune.ts index 57a159ca5..b096d3587 100644 --- a/site/source/api/commune.ts +++ b/site/source/api/commune.ts @@ -37,6 +37,7 @@ export async function searchCommunes( return null } const json = (await response.json()) as Array + return json .flatMap(({ codesPostaux, ...commune }) => codesPostaux @@ -68,6 +69,7 @@ export async function fetchCommuneDetails( if (taux === null) { return null } + return { ...commune, 'taux du versement transport': taux, diff --git a/site/source/api/fabrique-social.ts b/site/source/api/fabrique-social.ts index 579dc387f..60e5b5b35 100644 --- a/site/source/api/fabrique-social.ts +++ b/site/source/api/fabrique-social.ts @@ -64,5 +64,6 @@ async function searchFullText( } const json: FabriqueSocialSearchPayload = await response.json() + return json.entreprises } diff --git a/site/source/api/sirene.ts b/site/source/api/sirene.ts index 69ecf8a3f..5c17baf48 100644 --- a/site/source/api/sirene.ts +++ b/site/source/api/sirene.ts @@ -14,6 +14,7 @@ export async function fetchCompanyDetails(siren: string) { return null } const json = await response.json() + return json.unite_legale } @@ -24,6 +25,7 @@ export async function searchDenominationOrSiren(value: string) { if (isSIREN(value)) { return [{ siren: value }] } + return searchFullText(value) } diff --git a/site/source/components/Banner.tsx b/site/source/components/Banner.tsx index 42bda40a0..290bf860e 100644 --- a/site/source/components/Banner.tsx +++ b/site/source/components/Banner.tsx @@ -34,6 +34,7 @@ export default function Banner({ const hiddenState = useSelector(firstStepCompletedSelector) const hidden = hiddenProp || (hideAfterFirstStep && hiddenState) + return !hidden ? ( diff --git a/site/source/components/BarChart.tsx b/site/source/components/BarChart.tsx index 4679970d3..baf8a059e 100644 --- a/site/source/components/BarChart.tsx +++ b/site/source/components/BarChart.tsx @@ -37,6 +37,7 @@ function ChartItemBar({ }, flex: display ? percentage : 0, }) + return (
{disableAnimation ? ( diff --git a/site/source/components/EngineValue.tsx b/site/source/components/EngineValue.tsx index 43afc6728..5d04cfe5b 100644 --- a/site/source/components/EngineValue.tsx +++ b/site/source/components/EngineValue.tsx @@ -53,6 +53,7 @@ export default function Value({ ) } + return {value} } @@ -61,6 +62,7 @@ type ConditionProps = { defaultIfNotYetDefined?: boolean children: React.ReactNode } + export function Condition({ expression, defaultIfNotYetDefined = false, @@ -82,6 +84,7 @@ export function Condition({ if (!boolValue) { return null } + return <>{children} } @@ -96,6 +99,7 @@ export function WhenApplicable({ if (engine.evaluate(dottedName).nodeValue == null) { return null } + return <>{children} } export function WhenNotApplicable({ @@ -109,6 +113,7 @@ export function WhenNotApplicable({ if (engine.evaluate(dottedName).nodeValue !== null) { return null } + return <>{children} } @@ -123,6 +128,7 @@ export function WhenAlreadyDefined({ if (isNotYetDefined(engine.evaluate(dottedName).nodeValue)) { return null } + return <>{children} } @@ -137,5 +143,6 @@ export function WhenNotAlreadyDefined({ if (!isNotYetDefined(engine.evaluate(dottedName).nodeValue)) { return null } + return <>{children} } diff --git a/site/source/components/Feedback/index.tsx b/site/source/components/Feedback/index.tsx index bf06f382a..544c825ee 100644 --- a/site/source/components/Feedback/index.tsx +++ b/site/source/components/Feedback/index.tsx @@ -34,6 +34,7 @@ const askFeedback = (url: string) => { if (!previousFeedbackDate) { return true } + return ( new Date(previousFeedbackDate) < new Date(new Date().setMonth(new Date().getMonth() - 4)) diff --git a/site/source/components/LegalNotice.tsx b/site/source/components/LegalNotice.tsx index 3def200a2..4e7852b4a 100644 --- a/site/source/components/LegalNotice.tsx +++ b/site/source/components/LegalNotice.tsx @@ -6,6 +6,7 @@ import { Trans, useTranslation } from 'react-i18next' export default function LegalNotice() { const { t } = useTranslation() + return ( ( diff --git a/site/source/components/PaySlip.tsx b/site/source/components/PaySlip.tsx index 48ebac15b..086ba383a 100644 --- a/site/source/components/PaySlip.tsx +++ b/site/source/components/PaySlip.tsx @@ -37,6 +37,7 @@ function getSection(rule: RuleNode): Section { if (SECTION_ORDER.includes(section)) { return section } + return 'protection sociale . autres' } @@ -75,11 +76,13 @@ export function getCotisationsBySection( ) .reduce((acc, cotisation: DottedName) => { const sectionName = getSection(parsedRules[cotisation]) + return { ...acc, [sectionName]: (acc[sectionName] ?? new Set()).add(cotisation), } }, {} as Record>) + return Object.entries(cotisations) .map(([section, dottedNames]) => [section, [...dottedNames.values()]]) .sort( @@ -132,6 +135,7 @@ export default function PaySlip() { {cotisationsBySection.map(([sectionDottedName, cotisations]) => { const section = parsedRules[sectionDottedName] + return (
@@ -231,6 +235,7 @@ function Cotisation({ dottedName }: { dottedName: DottedName }) { if (!partPatronale.nodeValue && !partSalariale.nodeValue) { return null } + return ( <> diff --git a/site/source/components/PaySlipSections.tsx b/site/source/components/PaySlipSections.tsx index cd66297b8..5391cfc13 100644 --- a/site/source/components/PaySlipSections.tsx +++ b/site/source/components/PaySlipSections.tsx @@ -30,6 +30,7 @@ export const SalaireBrutSection = () => { export const SalaireNetSection = () => { const { t } = useTranslation() + return (

@@ -89,8 +90,9 @@ export function Line({ // ⚠️ isNotApplicable is a bad func only here to help with further refactoring: isNotApplicable(evaluatedNode.nodeValue) || evaluatedNode.nodeValue === 0 - ) + ) { return null + } return ( 0`}> diff --git a/site/source/components/PeriodSwitch.tsx b/site/source/components/PeriodSwitch.tsx index 0c38b8103..02d83d599 100644 --- a/site/source/components/PeriodSwitch.tsx +++ b/site/source/components/PeriodSwitch.tsx @@ -19,6 +19,7 @@ export default function PeriodSwitch() { unit: '€/an', }, ] + return (
{ const handler = setTimeout(() => setLinkCopied(false), 5000) + return () => { clearTimeout(handler) } diff --git a/site/source/components/ShareSimulationBanner/index.tsx b/site/source/components/ShareSimulationBanner/index.tsx index e7b5b68ad..9a0492f60 100644 --- a/site/source/components/ShareSimulationBanner/index.tsx +++ b/site/source/components/ShareSimulationBanner/index.tsx @@ -34,6 +34,7 @@ export function useUrl() { : import.meta.env.VITE_EN_BASE_URL searchParams.set('utm_source', 'sharing') + return siteUrl + path + '?' + searchParams.toString() } diff --git a/site/source/components/Simulation/Questions.tsx b/site/source/components/Simulation/Questions.tsx index 541e72fe4..dda45962a 100644 --- a/site/source/components/Simulation/Questions.tsx +++ b/site/source/components/Simulation/Questions.tsx @@ -13,6 +13,7 @@ const QuestionsContainer = styled.div` `0 0 ${theme.box.borderRadius} ${theme.box.borderRadius}`}; background: ${({ theme }) => { const colorPalette = theme.colors.bases.primary + return `linear-gradient(60deg, ${colorPalette[200]} 0%, ${colorPalette[100]} 100%);` }}; ` diff --git a/site/source/components/Simulation/SimulationGoal.tsx b/site/source/components/Simulation/SimulationGoal.tsx index 00f9332f6..2cbeb4e06 100644 --- a/site/source/components/Simulation/SimulationGoal.tsx +++ b/site/source/components/Simulation/SimulationGoal.tsx @@ -77,6 +77,7 @@ export function SimulationGoal({ ) { return null } + return ( diff --git a/site/source/components/Simulation/SimulationGoals.tsx b/site/source/components/Simulation/SimulationGoals.tsx index 8aa76e7c6..5d74f0ebc 100644 --- a/site/source/components/Simulation/SimulationGoals.tsx +++ b/site/source/components/Simulation/SimulationGoals.tsx @@ -68,6 +68,7 @@ const StyledSimulationGoals = styled.div< const colorPalette = publique ? theme.colors.publics[publique] : theme.colors.bases.primary + return css`linear-gradient(60deg, ${colorPalette[800]} 0%, ${colorPalette[600]} 100%);` }}; diff --git a/site/source/components/Simulation/index.tsx b/site/source/components/Simulation/index.tsx index d3c278521..187e67c7a 100644 --- a/site/source/components/Simulation/index.tsx +++ b/site/source/components/Simulation/index.tsx @@ -52,6 +52,7 @@ export default function Simulation({ const existingCompany = !!useSelector(companySituationSelector)[ 'entreprise . SIREN' ] + return ( <> {!firstStepCompleted && } diff --git a/site/source/components/StackedBarChart.tsx b/site/source/components/StackedBarChart.tsx index acc3815c8..0bd15bc7e 100644 --- a/site/source/components/StackedBarChart.tsx +++ b/site/source/components/StackedBarChart.tsx @@ -65,6 +65,7 @@ type Precision = 1 | 0.1 | 0.01 function integerAndDecimalParts(value: number) { const integer = Math.floor(value) const decimal = value - integer + return { integer, decimal } } @@ -104,6 +105,7 @@ export function roundedPercentages( precision: Precision ) { const logScale = Math.log10(precision) + return simpleRoundedPer(values, logScale).map( (int) => int / Math.pow(10, -logScale) ) @@ -128,6 +130,7 @@ export function StackedBarChart({ }) const styles = useSpring({ opacity: displayChart ? 1 : 0 }) + return !useContext(DisableAnimationContext) ? ( @@ -147,6 +150,7 @@ function InnerStackedBarChart({ data, precision }: InnerStackedBarChartProps) { ...data, percentage: percentages[index], })) + return ( <> @@ -190,6 +194,7 @@ export default function StackedRulesChart({ }: StackedRulesChartProps) { const engine = useEngine() const targetUnit = useSelector(targetUnitSelector) + return ( window.removeEventListener('click', onClickOutside) }, []) const situation = useSelector(situationSelector) diff --git a/site/source/components/conversation/ChoicesInput.tsx b/site/source/components/conversation/ChoicesInput.tsx index 7e1e71f91..c13c1e06e 100644 --- a/site/source/components/conversation/ChoicesInput.tsx +++ b/site/source/components/conversation/ChoicesInput.tsx @@ -53,6 +53,7 @@ export function MultipleAnswerInput({ // seront stockées ainsi dans le state : // [parent object path]: dotted fieldName relative to parent const { handleChange, defaultValue, currentSelection } = useSelection(props) + return ( { - if (!value || typeof value !== 'string') return undefined + if (!value || typeof value !== 'string') { + return undefined + } const [day, month, year] = value.split('/') + return `${year}-${month}-${day}` }, [value]) // const [currentValue, setCurrentValue] = useState(dateValue) @@ -38,6 +41,7 @@ export default function DateInput({ }, [onChange] ) + return (
diff --git a/site/source/components/conversation/Explicable.tsx b/site/source/components/conversation/Explicable.tsx index 6000f8bca..5f8bd7645 100644 --- a/site/source/components/conversation/Explicable.tsx +++ b/site/source/components/conversation/Explicable.tsx @@ -14,10 +14,14 @@ export function ExplicableRule({ const engine = useContext(EngineContext) // Rien à expliquer ici, ce n'est pas une règle - if (dottedName == null) return null + if (dottedName == null) { + return null + } const rule = engine.getRule(dottedName) - if (rule.rawNode.description == null) return null + if (rule.rawNode.description == null) { + return null + } //TODO montrer les variables de type 'une possibilité' diff --git a/site/source/components/conversation/InputSuggestions.tsx b/site/source/components/conversation/InputSuggestions.tsx index 87fe17aab..389170a01 100644 --- a/site/source/components/conversation/InputSuggestions.tsx +++ b/site/source/components/conversation/InputSuggestions.tsx @@ -24,6 +24,7 @@ export default function InputSuggestions({ if (!suggestions || !Object.keys(suggestions).length) { return null } + return ( {toPairs(suggestions).map(([text, value]: [string, ASTNode]) => { @@ -32,8 +33,11 @@ export default function InputSuggestions({ key={text} onPress={() => { onFirstClick(value) - if (suggestion !== value) setSuggestion(value) - else onSecondClick && onSecondClick(value) + if (suggestion !== value) { + setSuggestion(value) + } else { + onSecondClick && onSecondClick(value) + } }} title={t('cliquez pour insérer cette suggestion')} > diff --git a/site/source/components/conversation/NumberInput.tsx b/site/source/components/conversation/NumberInput.tsx index e8a0c9759..7fa7d09df 100644 --- a/site/source/components/conversation/NumberInput.tsx +++ b/site/source/components/conversation/NumberInput.tsx @@ -52,6 +52,7 @@ export default function NumberInput({ ...formatOptions, } const debouncedOnChange = useCallback(debounce(1000, onChange), []) + return ( ) } - if (rule.rawNode.API && rule.rawNode.API === 'commune') + if (rule.rawNode.API && rule.rawNode.API === 'commune') { return - if (rule.rawNode.API && rule.rawNode.API.startsWith('pays détachement')) + } + if (rule.rawNode.API && rule.rawNode.API.startsWith('pays détachement')) { return ( ) - if (rule.rawNode.API) + } + if (rule.rawNode.API) { throw new Error("Les seules API implémentées sont 'commune'") + } - if (rule.dottedName == 'contrat salarié . ATMP . taux collectif ATMP') + if (rule.dottedName == 'contrat salarié . ATMP . taux collectif ATMP') { return + } if (rule.rawNode.type === 'date') { return @@ -162,11 +166,14 @@ export const buildVariantTree = ( path: Name ): Choice => { const node = engine.getRule(path) - if (!node) throw new Error(`La règle ${path} est introuvable`) + if (!node) { + throw new Error(`La règle ${path} est introuvable`) + } const variant = getVariant(node) const canGiveUp = variant && (!variant['choix obligatoire'] || variant['choix obligatoire'] === 'non') + return Object.assign( node, variant diff --git a/site/source/components/conversation/TextInput.tsx b/site/source/components/conversation/TextInput.tsx index f5bd92963..f8bcf66f9 100644 --- a/site/source/components/conversation/TextInput.tsx +++ b/site/source/components/conversation/TextInput.tsx @@ -13,6 +13,7 @@ export default function TextInput({ autoFocus, }: InputProps & { value: Evaluation }) { const debouncedOnChange = useCallback(debounce(1000, onChange), []) + return ( {searchResults.map((result, i) => { const nom = formatCommune(result) + return (