-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
useEffect(() => { | ||
setDefaultFilters( | ||
transportModeFilter | ||
?.filter((filter) => filter.icon.transportMode !== 'air') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this always filter out air, regardless if the user has manually enabled it to see flights?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the user can manually set check the air filter after the initial search.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, because the transportModeFilter
never changes, which means that the useEffect
only runs once. In theory at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about when refreshing the page / opening a link with airplane filter enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of now, refreshing the page will reset the filters to default where flight is unchecked. Opening a link with flight filter checked is works as it should, where both trip with and without flights are displayed correctly. But, when navigating back to search results from detailed view, the filters are reset again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like the URL state is not prioritized and that this would override it 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Navigating back causes the will reset the trip query to not contain a transport mode filter, causing the useEffect to run again is my guess. Using setValuesWithLoading
would remediate that, wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea was that something like this would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that, everything didn't work.
I think the approach with using onTransportFilterChanged
might be a good solution.
Also need to make a change with "All", something like below. Setting the filter to all of the options instead of null
. (Need to handle when data
is undefined or null or whatever).
planner-web/src/modules/transport-mode/filter/filter.tsx
Lines 53 to 55 in 2dec3a0
onChange={(event) => { | |
onChangeWrapper(event.target.checked ? null : []); | |
}} |
onChange={(event) => {
onChangeWrapper(
event.target.checked ? data?.map((option) => option.id) : [],
);
}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey👍
useEffect(() => { | ||
if (tripQuery.transportModeFilter === null) | ||
onTransportFilterChanged( | ||
transportModeFilter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this logic be added directly to the onTransportFilterChanged
and this hook can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that is possible, as the transportModeFilter initially is null before the useSWRImmutable() have returned the results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also other reasons that I did not see before.
But this should be fixed:
ESLint: React Hook useEffect has missing dependencies: 'onTransportFilterChanged' and 'tripQuery.transportModeFilter'. Either include them or remove the dependency array.(react-hooks/exhaustive-deps)
Temporary solution for task https://github.com/orgs/AtB-AS/projects/10/views/13?pane=issue&itemId=51482158
Background
NFK have requested that flights are not part of the default transport methods in travel planner web. It should still be possible to enable for the users, but not selected as default.
This is default also in app and at Entur.
Illustrations
screenshot
Proposed solution
Disabling the travel planner flight filter for for all organisations until a more sophisticated solution where each organisation can configure filter preferences.
Acceptance Criteria