{"version":3,"file":"place-search-C4hEpuEp.js","sources":["../../../app/frontend/javascript/hooks/onClickOutside.jsx","../../../app/frontend/javascript/search/context/property-context.jsx","../../../app/frontend/javascript/hooks/retrievePlace.tsx","../../../app/frontend/javascript/components/icons/Pin.tsx","../../../app/frontend/javascript/place-search/components/suggestion.tsx","../../../app/frontend/javascript/place-search/place-search.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\nconst useOnClickOutside = (ref, handler) => {\n useEffect(\n () => {\n const listener = (event) => {\n // Do nothing if clicking ref's element or descendent elements\n if (!ref.current || ref.current.contains(event.target)) {\n return;\n }\n handler(event);\n };\n document.addEventListener(\"mousedown\", listener);\n document.addEventListener(\"touchstart\", listener);\n return () => {\n document.removeEventListener(\"mousedown\", listener);\n document.removeEventListener(\"touchstart\", listener);\n };\n },\n // Add ref and handler to effect dependencies\n // It's worth noting that because passed in handler is a new ...\n // ... function on every render that will cause this effect ...\n // ... callback/cleanup to run every render. It's not a big deal ...\n // ... but to optimize you can wrap handler in useCallback before ...\n // ... passing it into this hook.\n [ref, handler],\n );\n};\n\nexport default useOnClickOutside;\n","import React, { useState, createContext, useEffect } from \"react\";\n\nconst PropertyContext = createContext();\n\nconst PropertyContextProvider = ({ children }) => {\n const [properties, setProperties] = useState([]);\n const [filters, setFilters] = useState({});\n const [meta, setMeta] = useState({});\n\n const sendToListhub = (properties) => {\n const listhubProperties = properties.reduce((arr, prop) => {\n if (prop.listhub_key) {\n arr.push({ lkey: prop.listhub_key });\n }\n\n return arr;\n }, []);\n\n lh(\"submit\", \"SEARCH_DISPLAY\", listhubProperties);\n };\n\n useEffect(() => {\n getProperties();\n }, [filters]);\n\n useEffect(() => {\n sendToListhub(properties);\n }, [properties]);\n\n const buildUrl = () => {\n let url = `/map/properties?`;\n for (const key in filters) {\n const value = filters[key];\n if (Array.isArray(value)) {\n value.forEach((value) => {\n url += `&${key}[]=${value}`;\n });\n } else {\n url += `&${key}=${value}`;\n }\n }\n\n return url;\n };\n\n const getProperties = async () => {\n if (filters.zoom < 10) return;\n\n try {\n const response = await fetch(buildUrl(), {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n const json = await response.json();\n\n setProperties(json.properties);\n setMeta(json.meta_data);\n } catch (e) {\n console.log(e);\n }\n };\n return (\n
{suggestion.name}
\n{suggestion.place_formatted}
\n