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

fix: set filter correctly when navigating back from details page #263

Merged
merged 8 commits into from
Mar 19, 2024
2 changes: 2 additions & 0 deletions src/page-modules/assistant/details/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function tripQueryStringToQueryParams(
)
return undefined;

const filter = queryString.split('filter=')[1];
jonasbrunvoll marked this conversation as resolved.
Show resolved Hide resolved
const searchMode = arriveBy ? 'arriveBy' : 'departBy';
const fromLayer = from.place?.includes('StopPlace') ? 'venue' : 'address';
const toLayer = to.place?.includes('StopPlace') ? 'venue' : 'address';
Expand All @@ -57,6 +58,7 @@ export function tripQueryStringToQueryParams(
);

const params = {
filter,
searchMode,
searchTime,
fromId: from.place,
Expand Down
6 changes: 5 additions & 1 deletion src/page-modules/assistant/server/journey-planner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,11 @@ function generateSingleTripQueryString(

// encode to string
return compressToEncodedURIComponent(
JSON.stringify({ query: singleTripQuery, journeyIds, originalSearchTime }),
JSON.stringify({
query: singleTripQuery,
journeyIds,
originalSearchTime,
}),
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/page-modules/assistant/trip/trip-pattern/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MonoIcon } from '@atb/components/icon';
import { Typo } from '@atb/components/typography';
import { TransportIconWithLabel } from '@atb/modules/transport-mode';
import { andIf } from '@atb/utils/css';
import { useRouter } from 'next/router';
mortennordseth marked this conversation as resolved.
Show resolved Hide resolved

const LAST_LEG_PADDING = 20;
const DEFAULT_THRESHOLD_AIMED_EXPECTED_IN_SECONDS = 60;
Expand All @@ -31,6 +32,7 @@ export default function TripPattern({
const { t, language } = useTranslation();

const filteredLegs = getFilteredLegsByWalkOrWaitTime(tripPattern);
const router = useRouter();

const [numberOfExpandedLegs, setNumberOfExpandedLegs] = useState(
filteredLegs.length,
Expand Down Expand Up @@ -70,7 +72,7 @@ export default function TripPattern({

return (
<motion.a
href={`/assistant/${tripPattern.compressedQuery}`}
href={`/assistant/${tripPattern.compressedQuery}&filter=${router.query.filter}`}
jonasbrunvoll marked this conversation as resolved.
Show resolved Hide resolved
className={className}
data-testid={testId}
initial={{ opacity: 0, x: -10 }}
Expand Down
Loading