Skip to content

Commit 09a5b46

Browse files
committed
Fix: Prevent auto-redirect to map view when applying state filter in chart view
1 parent d8b06d4 commit 09a5b46

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/[locale]/[state]/analytics/components/filter-component.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import React, { useCallback, useEffect, useState } from 'react';
4-
import { useParams, useRouter } from 'next/navigation';
4+
import { useParams, useRouter, useSearchParams } from 'next/navigation';
55
import { parseDate } from '@internationalized/date';
66
import { parseAsString, useQueryState } from 'next-usequerystate';
77
import { Button, Icon, RadioGroup, RadioItem, YearCalendar } from 'opub-ui';
@@ -234,12 +234,14 @@ export const RenderOptions = ({
234234
const type = findSelectedValue[0]?.type;
235235
const value = findSelectedValue[0]?.value;
236236
const options = findSelectedValue[0]?.options;
237+
const searchParams = useSearchParams();
238+
const view = searchParams.get('view');
237239

238240
const onRadioButtonChange = (selectedValue: string, value: string) => {
239241
if (value === 'state') {
240242
setSelectedState(selectedValue);
241243
router.push(
242-
`/${selectedValue}/analytics/?indicator=risk-score&time-period=${process.env.TIME_PERIOD || process.env.NEXT_PUBLIC_TIME_PERIOD}&view=map`
244+
`/${selectedValue}/analytics/?indicator=risk-score&time-period=${process.env.TIME_PERIOD || process.env.NEXT_PUBLIC_TIME_PERIOD}&view=${view}`
243245
);
244246
// console.log('---Selected State ---', selectedState);
245247
} else if (value === 'district') {

0 commit comments

Comments
 (0)