diff --git a/.eslintrc.json b/.eslintrc.json index 2a634d3b..5fa66925 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -59,6 +59,12 @@ { "from": "./features", "target": "./components" } ] } + ], + "prettier/prettier": [ + "error", + { + "endOfLine": "auto" + } ] } } diff --git a/components/Filters/components/Toggle/Toggle.tsx b/components/Filters/components/Toggle/Toggle.tsx index 75206c63..46fa805b 100644 --- a/components/Filters/components/Toggle/Toggle.tsx +++ b/components/Filters/components/Toggle/Toggle.tsx @@ -1,5 +1,6 @@ -import React, { useCallback } from 'react'; +import { useCallback } from 'react'; +import { useRouter } from 'next/router'; import { FilterType } from 'types/Filters.types'; import styles from './Toggle.module.css'; @@ -13,9 +14,16 @@ export interface ToggleProps { } export function Toggle({ id, label, onClick, type, isActive }: ToggleProps) { + const router = useRouter(); + const onChange = useCallback(() => { onClick(type); - }, [type, onClick]); + router.push({ + pathname: '/', + query: type === FilterType.HouseAge ? {} : { filter: type }, + hash: window.location.hash.slice(1), + }); + }, [onClick, type, router]); return (