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

Remove router filter from map/list view. #3898

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions source/frontend/src/features/properties/filter/PropertyFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ResetButton, SearchButton } from '@/components/common/buttons';
import { Form, Input, Select } from '@/components/common/form';
import { TableSort } from '@/components/Table/TableSort';
import { useGeocoderRepository } from '@/hooks/useGeocoderRepository';
import { useRouterFilter } from '@/hooks/useRouterFilter';
import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts_Property';
import { FilterBarSchema } from '@/utils/YupSchema';

Expand Down Expand Up @@ -41,27 +40,13 @@ export interface IPropertyFilterProps {
export const PropertyFilter: React.FC<React.PropsWithChildren<IPropertyFilterProps>> = ({
defaultFilter,
onChange,
sort,
onSorting,
toggle = SearchToggleOption.Map,
useGeocoder,
}) => {
const [propertyFilter, setPropertyFilter] = useState<IPropertyFilter>(defaultFilter);

const { getSitePids } = useGeocoderRepository();

useRouterFilter<IPropertyFilter>({
filter: propertyFilter,
setFilter: filter => {
onChange(filter);
setPropertyFilter(filter);
},
key: 'propertyFilter',
sort: sort,
setSorting: onSorting,
exactPath: '/mapview',
});

const history = useHistory();
const initialValues = useMemo(() => {
const values = { ...defaultFilter, ...propertyFilter };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { MultiSelectOption } from '@/features/acquisition/list/interfaces';
import { useApiProperties } from '@/hooks/pims-api/useApiProperties';
import { useProperties } from '@/hooks/repositories/useProperties';
import useLookupCodeHelpers from '@/hooks/useLookupCodeHelpers';
import { useRouterFilter } from '@/hooks/useRouterFilter';
import useDeepCompareEffect from '@/hooks/util/useDeepCompareEffect';
import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts_Property';
import { generateMultiSortCriteria } from '@/utils';
Expand Down Expand Up @@ -63,25 +62,13 @@ const PropertyListView: React.FC<React.PropsWithChildren<unknown>> = () => {

const fetchIdRef = useRef(0);

const parsedFilter = useMemo(() => {
const data = { ...filter };
return data;
}, [filter]);

const { updateSearch } = useRouterFilter({
filter: parsedFilter,
setFilter: setFilter,
key: 'propertyFilter',
});

// Update internal state whenever the filter bar state changes
const handleFilterChange = useCallback(
(value: IPropertyFilter) => {
setFilter({ ...value });
updateSearch({ ...value });
setPageIndex(0); // Go to first page of results when filter changes
},
[setFilter, setPageIndex, updateSearch],
[setFilter, setPageIndex],
);
// This will get called when the table needs new data
const onRequestData = useCallback(
Expand Down
136 changes: 0 additions & 136 deletions source/frontend/src/hooks/useRouterFilter.test.tsx

This file was deleted.

158 changes: 0 additions & 158 deletions source/frontend/src/hooks/useRouterFilter.ts

This file was deleted.