Skip to content

Commit

Permalink
Updatet logic and test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbrunvoll committed Feb 28, 2024
1 parent 2dec3a0 commit f06409f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
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
26 changes: 16 additions & 10 deletions src/page-modules/assistant/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ function AssistantLayout({ children, tripQuery }: AssistantLayoutProps) {
getTransportModeFilter,
);

useEffect(() => {
if (tripQuery.transportModeFilter === null)
onTransportFilterChanged(
transportModeFilter
?.filter((filter) => filter.id !== 'air')
.map((filter) => filter.id) ?? null,
);
}, [transportModeFilter]);

const setValuesWithLoading = async (
override: Partial<FromToTripQuery>,
replace = false,
Expand Down Expand Up @@ -131,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

0 comments on commit f06409f

Please sign in to comment.