Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: disable travel planner flight filter by default #242

Merged
merged 8 commits into from
Feb 28, 2024
Merged
10 changes: 9 additions & 1 deletion src/modules/transport-mode/filter/__tests__/filter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ describe('transport mode filter', () => {

const initial: string[] = [];

const expected = null;
const expected = [
'bus',
'rail',
'expressboat',
'ferry',
'airportbus',
'air',
'other',
];

render(
<TransportModeFilter
Expand Down
4 changes: 3 additions & 1 deletion src/modules/transport-mode/filter/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export default function TransportModeFilter({
!localFilterState || localFilterState.length === data.length
}
onChange={(event) => {
onChangeWrapper(event.target.checked ? null : []);
onChangeWrapper(
event.target.checked ? data?.map((option) => option.id) : [],
);
}}
/>

Expand Down
24 changes: 22 additions & 2 deletions src/page-modules/assistant/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -117,8 +122,23 @@ function AssistantLayout({ children, tripQuery }: AssistantLayoutProps) {
const { urls, orgId } = getOrgData();
const { isDarkMode } = useTheme();

/*
* Temporary solution until firebase configuration is in place.
*/
useEffect(() => {
if (tripQuery.transportModeFilter === null)
onTransportFilterChanged(
transportModeFilter
?.filter(
(filter) =>
!filter.modes.some((mode) => mode.transportMode === 'air'),
)
.map((filter) => filter.id) ?? null,
);
}, [transportModeFilter]);

/**
* Temprorary solution to disable line filter for some orgs until
* Temporary solution to disable line filter for some orgs until
* we have a working solution for all orgs.
*/
const disableLineFilter =
Expand Down
Loading