From 918c7f95922d68031ae146c119d2708d37ba1192 Mon Sep 17 00:00:00 2001 From: Jonas Brunvoll Larsson Date: Mon, 26 Feb 2024 14:40:39 +0100 Subject: [PATCH] Added functionality ensures that only filters without the property isUncheckedByDefault is initially checked. --- src/page-modules/assistant/layout.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/page-modules/assistant/layout.tsx b/src/page-modules/assistant/layout.tsx index 39a5b8ea..60a0d4d1 100644 --- a/src/page-modules/assistant/layout.tsx +++ b/src/page-modules/assistant/layout.tsx @@ -16,7 +16,12 @@ import { PageText, useTranslation } from '@atb/translations'; import { FocusScope } from '@react-aria/focus'; import { AnimatePresence, motion } from 'framer-motion'; import { useRouter } from 'next/router'; -import { FormEventHandler, PropsWithChildren, useState } from 'react'; +import { + FormEventHandler, + PropsWithChildren, + useEffect, + useState, +} from 'react'; import style from './assistant.module.css'; import { FromToTripQuery } from './types'; import { createTripQuery } from './utils'; @@ -54,6 +59,13 @@ function AssistantLayout({ children, tripQuery }: AssistantLayoutProps) { getTransportModeFilter, ); + useEffect(() => { + tripQuery.transportModeFilter = + transportModeFilter + ?.filter((filter: any) => !filter.isUncheckedByDefault) + .map((filter: any) => filter.id) ?? null; + }, [transportModeFilter]); + const setValuesWithLoading = async ( override: Partial, replace = false,