@@ -2,10 +2,11 @@ import { useTranslation } from "next-i18next"
22import { RefinementList , useInstantSearch } from "react-instantsearch"
33import { faFilter } from "@fortawesome/free-solid-svg-icons"
44import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
5- import { useCallback , useEffect , useState } from "react"
5+ import { useCallback , useState } from "react"
66import styled from "styled-components"
77import { useMediaQuery } from "usehooks-ts"
8- import { Button , Col , Offcanvas } from "../bootstrap"
8+ import { Button , Offcanvas } from "../bootstrap"
9+ import { MultiselectHierarchicalMenu } from "./HierarchicalMenuWidget"
910import { SearchContainer } from "./SearchContainer"
1011
1112export const FilterButton = styled ( Button ) `
@@ -15,15 +16,18 @@ export const FilterButton = styled(Button)`
1516 padding: 0.25rem 0.5rem 0.25rem 0.5rem;
1617 align-self: flex-start;
1718`
19+
1820const useHasRefinements = ( ) => {
1921 const { results } = useInstantSearch ( )
2022 const refinements = results . getRefinements ( )
2123 return refinements . length !== 0
2224}
2325
2426export const useRefinements = ( {
27+ hierarchicalMenuProps,
2528 refinementProps
2629} : {
30+ hierarchicalMenuProps : any [ ]
2731 refinementProps : any [ ]
2832} ) => {
2933 const inline = useMediaQuery ( "(min-width: 768px)" )
@@ -38,19 +42,35 @@ export const useRefinements = ({
3842 ) ) }
3943 </ >
4044 )
45+
46+ const hierarchicalMenu = (
47+ < >
48+ < MultiselectHierarchicalMenu
49+ attributes = { [
50+ hierarchicalMenuProps [ 0 ] . attribute ,
51+ hierarchicalMenuProps [ 1 ] . attribute
52+ ] }
53+ />
54+ </ >
55+ )
56+
4157 const hasRefinements = useHasRefinements ( )
4258
4359 const { t } = useTranslation ( "billSearch" )
4460
4561 return {
4662 options : inline ? (
47- < div > { refinements } </ div >
63+ < >
64+ < div > { hierarchicalMenu } </ div >
65+ < div > { refinements } </ div >
66+ </ >
4867 ) : (
4968 < Offcanvas show = { show } onHide = { handleClose } >
5069 < Offcanvas . Header closeButton >
5170 < Offcanvas . Title > { t ( "filter" ) } </ Offcanvas . Title >
5271 </ Offcanvas . Header >
5372 < Offcanvas . Body >
73+ < SearchContainer > { hierarchicalMenu } </ SearchContainer >
5474 < SearchContainer > { refinements } </ SearchContainer >
5575 </ Offcanvas . Body >
5676 </ Offcanvas >
0 commit comments