{"version":3,"sources":["webpack:///./Scripts/Components/GoogleReview.js","webpack:///./Scripts/Hooks/useGeolocationPosition.js","webpack:///./Scripts/Hooks/useGoogleMaps.js","webpack:///./Scripts/Hooks/useNavigatorPermissionsQuery.js","webpack:///./Scripts/Hooks/useRefreshGeolocationPositionIfPermissionGranted.js","webpack:///./Scripts/Hooks/useSortedStations.js","webpack:///./Scripts/Services/GoogleMaps.js"],"names":["props","useState","reviews","setReviews","open","setOpen","ref","useRef","reviewRef","maps","useGoogleMaps","useEffect","current","location","LatLng","lat","long","service","places","PlacesService","Map","nearbySearch","keyword","radius","result","status","PlacesServiceStatus","OK","length","placeId","place_id","getDetails","fields","rating","reviewTotal","user_ratings_total","handleClickOutside","e","contains","target","document","addEventListener","removeEventListener","getStar","className","getRating","style","display","onClick","translate","map","item","index","key","author_name","relative_time_description","text","useGeolocationPosition","geolocationPosition","setGeolocationPosition","refreshGeolocationPosition","navigator","geolocation","getCurrentPosition","api","setApi","useNavigatorPermissionsQuery","query","setStatus","refreshStatus","permissions","then","useRefreshGeolocationPositionIfPermissionGranted","geolocationPermission","state","useSortedStations","stations","googleMaps","filter","station","onlyVisibleInTireHotel","sortedStations","setSortedStations","p0","coords","latitude","longitude","newSortedStations","sort","a","b","geometry","spherical","computeDistanceBetween","coordinatesLat","coordinatesLong","instance","promise","Promise","resolve","script","createElement","src","async","defer","onload","google","head","appendChild"],"mappings":"umCAkKA,QA9JqB,SAACA,GAAU,WAEEC,cAAS,MAFX,GAErBC,EAFqB,KAEZC,EAFY,UAGJF,eAAS,GAHL,GAGrBG,EAHqB,KAGfC,EAHe,KAMtBC,GAAMC,cACNC,GAAYD,cAGZE,GAAOC,WAEbC,gBAAU,WACN,GAAIF,GAAQH,EAAIM,UAAYV,EAAS,CACjC,IAAMW,EAAW,IAAIJ,EAAKK,OAAOd,EAAMe,IAAKf,EAAMgB,MAE5CC,EAAU,IAAIR,EAAKS,OAAOC,cAC5B,IAAIV,EAAKW,IAAId,EAAIM,UAErB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GAIZ,IAHCjB,EAGD,EAHCA,oBACAkB,EAED,EAFCA,SACAC,EACD,EADCA,WACD,KAC6C5E,cAAS2E,EAASE,QAAO,SAACC,GAAD,OAAcA,EAAQC,2BAD5F,GACQC,EADR,KACwBC,EADxB,KAyBC,OAtBAvE,gBAAU,WACN,GAAK+C,GAA2C,IAApBkB,EAAShD,QAAiBiD,EAAtD,CAGA,IAAMM,EAAK,IAAIN,EAAW/D,OACtB4C,EAAoB0B,OAAOC,SAC3B3B,EAAoB0B,OAAOE,WAEzBC,EAAoB,EAAIX,GAAUY,MACpC,SAACC,EAAGC,GAAJ,OACIb,EAAWc,SAASC,UAAUC,uBAC1B,IAAIhB,EAAW/D,OAAO2E,EAAEK,eAAgBL,EAAEM,iBAC1CZ,GAEJN,EAAWc,SAASC,UAAUC,uBAC1B,IAAIhB,EAAW/D,OAAO4E,EAAEI,eAAgBJ,EAAEK,iBAC1CZ,MAGZD,EAAkBK,MACnB,CAAC7B,EAAqBkB,EAAUC,IAE5BI,I,8CClCJ,IAAMxE,EAAO,CAChBuF,SAAU,KACVC,QAAS,IAAIC,SAAQ,SAACC,GAClB,IAAMC,EAAS5D,SAAS6D,cAAc,UACtCD,EAAOE,IACH,4IACJF,EAAOG,OAAQ,EACfH,EAAOI,OAAQ,EACfJ,EAAOK,OAAS,WACZhG,EAAKuF,SAAWU,OAAOjG,KACvB0F,EAAQ1F,EAAKuF,WAEjBxD,SAASmE,KAAKC,YAAYR","file":"364.b21a73bdad66e20e8a9b.js","sourcesContent":["import React, { useEffect, useState, useRef } from 'react'\r\nimport { useGoogleMaps } from '../Hooks'\r\nimport { translate } from '../Services/translation'\r\n\r\nconst GoogleReview = (props) => {\r\n // STATE\r\n const [reviews, setReviews] = useState(null)\r\n const [open, setOpen] = useState(false)\r\n\r\n // REFS\r\n const ref = useRef()\r\n const reviewRef = useRef()\r\n\r\n // HOOKS\r\n const maps = useGoogleMaps()\r\n\r\n useEffect(() => {\r\n if (maps && ref.current && !reviews) {\r\n const location = new maps.LatLng(props.lat, props.long)\r\n\r\n const service = new maps.places.PlacesService(\r\n new maps.Map(ref.current)\r\n )\r\n service.nearbySearch(\r\n {\r\n location,\r\n keyword: 'Däckskiftarna',\r\n radius: 1400,\r\n },\r\n (result, status) => {\r\n if (\r\n status == maps.places.PlacesServiceStatus.OK &&\r\n result?.length > 0\r\n ) {\r\n const placeId = result[0].place_id\r\n\r\n service.getDetails(\r\n {\r\n placeId,\r\n fields: [\r\n 'rating',\r\n 'reviews',\r\n 'user_ratings_total',\r\n ],\r\n },\r\n (result, status) => {\r\n if (\r\n status == maps.places.PlacesServiceStatus.OK\r\n ) {\r\n setReviews({\r\n rating: result.rating,\r\n reviews: result.reviews,\r\n reviewTotal: result.user_ratings_total,\r\n })\r\n }\r\n }\r\n )\r\n }\r\n }\r\n )\r\n }\r\n }, [maps, ref, reviews, setReviews])\r\n\r\n // Event listener for closing review modal when clicking outside\r\n useEffect(() => {\r\n const handleClickOutside = (e) => {\r\n if (\r\n open &&\r\n reviewRef.current &&\r\n !reviewRef.current.contains(e.target)\r\n ) {\r\n setOpen(false)\r\n }\r\n }\r\n\r\n document.addEventListener('click', handleClickOutside)\r\n\r\n return () => {\r\n document.removeEventListener('click', handleClickOutside)\r\n }\r\n }, [open, reviewRef])\r\n\r\n // Reusable elements\r\n const getStar = (rating) => {\r\n if (rating >= 0.29 && rating <= 0.71) {\r\n return \r\n } else if (rating > 0.71) {\r\n return \r\n } else {\r\n return \r\n }\r\n }\r\n\r\n const getRating = (rating) => {\r\n return (\r\n \r\n {getStar(rating)}\r\n {getStar(rating - 1)}\r\n {getStar(rating - 2)}\r\n {getStar(rating - 3)}\r\n {getStar(rating - 4)}\r\n \r\n )\r\n }\r\n\r\n return (\r\n <>\r\n
\r\n {reviews && (\r\n{item.text}
\r\n