{"version":3,"file":"static/js/933.fbcf1026.chunk.js","mappings":"0MAyCA,QAlCA,SAAqBA,GAAgB,IAAf,SAAEC,GAAUD,EAChC,MAAM,IAAEE,IAAQC,EAAAA,EAAAA,MACTC,EAASC,IAAcC,EAAAA,EAAAA,WAAS,GACjCC,GAAWC,EAAAA,EAAAA,MACXC,KAAYC,EAAAA,EAAAA,KAAYC,EAAAA,EAAAA,IAAgBT,IA2B9C,OAzBAU,EAAAA,EAAAA,YAAU,KACR,MAAMC,EAAa,IAAIC,gBAmBvB,OAlBgB,IAAZL,EACFM,MAAM,qBAAuBb,EAAM,QAAS,CAAEc,OAAQH,EAAWG,SAC9DC,MAAMC,IACL,IAAKA,EAASC,GAAI,MAAM,IAAIC,MAAM,wBAA0BF,EAASG,QACrE,OAAOH,EAASI,MAAM,IAEvBL,MAAMK,KACLC,EAAAA,EAAAA,IAAQhB,EAAUL,EAAKoB,EAAK,IAE7BE,OAAOC,IACNC,QAAQD,MAAM,UAAYA,EAAME,QAAQ,IAEzCC,SAAQ,KACPvB,GAAW,EAAK,IAGpBA,GAAW,GAEN,KACLQ,EAAWgB,OAAO,CACnB,GACA,CAAC3B,EAAKO,EAASF,IAEXH,EAAUH,GAAW6B,EAAAA,EAAAA,KAACC,EAAAA,EAAO,GACtC,C","sources":["HOC/WithParkData.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { useSelector, useDispatch } from 'react-redux';\nimport { useParams } from 'react-router';\nimport Loading from '../Components/Loading';\nimport { addPark } from '../Redux/actions';\nimport { getParkSelector } from '../Redux/selectors';\n\nfunction WithParkData({ children }) {\n const { pid } = useParams();\n const [hasData, setHasData] = useState(false);\n const dispatch = useDispatch();\n const hasPark = !!useSelector(getParkSelector(pid));\n\n useEffect(() => {\n const controller = new AbortController();\n if (hasPark === false) {\n fetch('/json/PARKDETAILS-' + pid + '.json', { signal: controller.signal })\n .then((response) => {\n if (!response.ok) throw new Error('HTTP error, status = ' + response.status);\n return response.json();\n })\n .then((json) => {\n addPark(dispatch, pid, json);\n })\n .catch((error) => {\n console.error('Error: ' + error.message);\n })\n .finally(() => {\n setHasData(true);\n });\n } else {\n setHasData(true);\n }\n return () => {\n controller.abort();\n };\n }, [pid, hasPark, dispatch]);\n\n return hasData ? children : ;\n}\n\nexport default WithParkData;\n"],"names":["_ref","children","pid","useParams","hasData","setHasData","useState","dispatch","useDispatch","hasPark","useSelector","getParkSelector","useEffect","controller","AbortController","fetch","signal","then","response","ok","Error","status","json","addPark","catch","error","console","message","finally","abort","_jsx","Loading"],"sourceRoot":""}