{"version":3,"sources":["components/search/AlternateSearchFilter.js"],"names":["SearchFilter","_ref","props","page","noLocation","loading","hadsearched","dispatch","useDispatch","lang","translate","useSelector","state","general","serviceFilter","search","filters","setFilters","useState","facilities","setFacilities","path","search_path","categoryID","keyboard","store","get","params","URLSearchParams","useLocation","urlItems","split","getFacilities","useCallback","async","axios","then","res","new_facilities","i","data","length","facility","name","new_item","code","id","icon","active","test","includes","toString","push","copy_search_facilities","useEffect","setTimeout","checkBoxHandler","index","copy","filter","e","updateFilter","React","createElement","className","style","animation","onClick","Icon","slice","map","title","key","src","alt","width","height","location","Link","to","Array","isArray","slug","keyword_value"],"mappings":"6FAAA,kHAyOeA,UA/NMC,IAAwD,IAAvD,MAAEC,EAAK,KAAEC,EAAI,WAAEC,EAAU,QAAEC,EAAO,YAAEC,GAAaL,EACrE,MAAMM,EAAWC,cACjB,IAAI,KAAEC,EAAI,UAAEC,GAAcC,YAAaC,GAAUA,EAAMC,UACnD,cAAEC,GAAkBH,YAAaC,GAAUA,EAAMG,SAChDC,EAASC,GAAcC,oBAAS,IAChCC,EAAYC,GAAiBF,mBAAS,IAEvCG,EAAOV,YAAaC,GAAUA,EAAMC,QAAQS,aAC5CP,EAASJ,YAAaC,GAAUA,EAAMG,QACtCQ,EAAaZ,YAAaC,GAAUA,EAAMG,OAAOQ,YACrD,MAAMC,EAAWC,IAAMC,IAAI,OAM3B,IAAIC,EAHK,IAAIC,gBAAgBC,cAAcd,QAGnBW,IAAI,WACxBI,EAAW,GACXH,IACFG,EAAWH,EAAOI,MAAM,MAG1B,MAAMC,EAAgBC,sBACpBC,gBACQC,IACHT,IACC,iEAAkEjB,GAEnE2B,KAAMC,IACL,IAAIC,EAAiB,GACrB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAIG,KAAKrB,WAAWsB,OAAQF,IAAK,CACnD,IAAIG,EAAWL,EAAIG,KAAKrB,WAAWoB,GAC/BI,EAAO,GACXA,EAAOD,EAASC,KAMhB,IAAIC,EAAW,C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,GAAMxD,EAAWwD,IAE1BlD,EAAU","file":"static/js/12.ef58d406.chunk.js","sourcesContent":["import { useDispatch, useSelector } from \"react-redux\";\r\nimport { updateFilter } from \"../../actions\";\r\nimport React, { useEffect, useState, useCallback } from \"react\";\r\nimport axios from \"axios\";\r\nimport { useLocation } from \"react-router-dom\";\r\nimport { Link } from \"react-router-dom\";\r\nimport store from \"store\";\r\nimport Icon from \"@identitybuilding/idb-react-iconlib\";\r\nimport { Search } from \"@identitybuilding/idb-react-iconlib/lib\";\r\n\r\nconst SearchFilter = ({ props, page, noLocation, loading, hadsearched }) => {\r\n const dispatch = useDispatch();\r\n let { lang, translate } = useSelector((state) => state.general);\r\n let { serviceFilter } = useSelector((state) => state.search);\r\n let [filters, setFilters] = useState(false);\r\n let [facilities, setFacilities] = useState([]);\r\n // let [searchFacilities, setSearchFacilities] = useState([])\r\n let path = useSelector((state) => state.general.search_path);\r\n let search = useSelector((state) => state.search);\r\n let categoryID = useSelector((state) => state.search.categoryID);\r\n const keyboard = store.get(\"vkb\");\r\n\r\n const useQuery = () => {\r\n return new URLSearchParams(useLocation().search);\r\n };\r\n\r\n let params = useQuery().get(\"service\");\r\n let urlItems = \"\";\r\n if (params) {\r\n urlItems = params.split(\",\");\r\n }\r\n\r\n const getFacilities = useCallback(\r\n async (test) => {\r\n await axios\r\n .get(\r\n `${process.env.REACT_APP_BASE_MEDIA_URL}/core/api/filters/?lang=${lang}`\r\n )\r\n .then((res) => {\r\n let new_facilities = [];\r\n for (let i = 0; i < res.data.facilities.length; i++) {\r\n let facility = res.data.facilities[i];\r\n let name = \"\";\r\n name = facility.name\r\n // facility[`name_${lang}`] ||\r\n // facility.name_nl ||\r\n // facility.name_fr ||\r\n // facility.name_de ||\r\n // facility.name_en;\r\n let new_item = {\r\n code: facility.id,\r\n icon: facility.icon,\r\n // facility.icon[`png_${lang}`] ||\r\n // facility.icon.png_nl ||\r\n // facility.icon.png_fr ||\r\n // facility.icon.png_de ||\r\n // facility.icon.png_en,\r\n name: name,\r\n active:\r\n // urlItems.includes(facility.id.toString()) ||\r\n // serviceFilter.includes(facility.id.toString()) ||\r\n test && test.includes(facility.id.toString()),\r\n };\r\n new_facilities.push(new_item);\r\n }\r\n setFacilities(new_facilities);\r\n\r\n // If the first item is not empty, dispatch it\r\n // if (urlItems.length > 0) {\r\n // dispatch(updateFilter(urlItems));\r\n // }\r\n });\r\n },\r\n [dispatch, lang]\r\n );\r\n\r\n let copy_search_facilities = serviceFilter;\r\n // if (typeof serviceFilter !== \"string\") {\r\n // for (let i = 0; i < serviceFilter.length; i++) {\r\n // copy_search_facilities.push(Number(serviceFilter[i]));\r\n // }\r\n // }\r\n useEffect(() => {\r\n getFacilities(serviceFilter);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (!page || page !== \"results\") {\r\n setTimeout(() => {\r\n setFilters(true);\r\n }, 500);\r\n setTimeout(() => {\r\n setFilters(false);\r\n }, 4000);\r\n }\r\n }, [page]);\r\n\r\n const checkBoxHandler = (index) => {\r\n // set facilities (in)active\r\n let copy = [...facilities];\r\n copy[index].active = !copy[index].active;\r\n setFacilities(copy);\r\n\r\n if (copy[index].active) {\r\n copy_search_facilities.push(copy[index].code.toString());\r\n } else {\r\n copy_search_facilities = copy_search_facilities.filter(\r\n (e) => e !== copy[index].code.toString()\r\n );\r\n // setSearchFacilities(copy_search_facilities);\r\n }\r\n dispatch(updateFilter(copy_search_facilities));\r\n };\r\n\r\n return (\r\n