@abcagency/hc-ui-components 1.4.8 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/HireControlMap.js +30 -5
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/contexts/placesContext.js +7 -6
- package/dist/contexts/placesContext.js.map +1 -1
- package/dist/services/googlePlacesNearbyService.js +2 -2
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/types/services/googlePlacesNearbyService.d.ts +1 -1
- package/package.json +7 -2
- package/src/components/HireControlMap.js +21 -3
- package/src/contexts/placesContext.js +6 -6
- package/src/services/googlePlacesNearbyService.ts +3 -2
|
@@ -12,7 +12,7 @@ import { ThemeProvider } from '../contexts/themeContext.js';
|
|
|
12
12
|
import { getMapConfig } from '../services/configService.js';
|
|
13
13
|
import { setClientAuthKey } from '../clientToken.js';
|
|
14
14
|
|
|
15
|
-
var _excluded = ["children", "siteConfig", "trackEvent"];
|
|
15
|
+
var _excluded = ["children", "siteConfig", "trackEvent", "googleMapsApiKey"];
|
|
16
16
|
|
|
17
17
|
// Libraries for Google Maps
|
|
18
18
|
var LIBRARIES = ['places'];
|
|
@@ -84,6 +84,7 @@ var ContextProviders = function ContextProviders(_ref2) {
|
|
|
84
84
|
var children = _ref2.children,
|
|
85
85
|
siteConfig = _ref2.siteConfig,
|
|
86
86
|
trackEvent = _ref2.trackEvent,
|
|
87
|
+
googleMapsApiKey = _ref2.googleMapsApiKey,
|
|
87
88
|
mapListProps = _objectWithoutProperties(_ref2, _excluded);
|
|
88
89
|
return /*#__PURE__*/React__default.createElement(TrackEventProvider, {
|
|
89
90
|
trackEvent: trackEvent
|
|
@@ -102,6 +103,7 @@ var ContextProviders = function ContextProviders(_ref2) {
|
|
|
102
103
|
}, /*#__PURE__*/React__default.createElement(PlacesProvider, {
|
|
103
104
|
placeMappings: (_siteConfig$pointsOfI = siteConfig.pointsOfInterestConfig.placeMappings) !== null && _siteConfig$pointsOfI !== void 0 ? _siteConfig$pointsOfI : {},
|
|
104
105
|
additionalMapMarkers: mapListProps.additionalMapMarkers,
|
|
106
|
+
googleMapsApiKey: googleMapsApiKey,
|
|
105
107
|
markerColors: {
|
|
106
108
|
fillColor: siteConfig.colors.primary,
|
|
107
109
|
strokeColor: siteConfig.colors.primaryDark,
|
|
@@ -120,6 +122,7 @@ var ContextProviders = function ContextProviders(_ref2) {
|
|
|
120
122
|
var HireControlMap = function HireControlMap(_ref3) {
|
|
121
123
|
var _siteConfig$pointsOfI2;
|
|
122
124
|
var clientToken = _ref3.clientToken,
|
|
125
|
+
googleMapsApiKey = _ref3.googleMapsApiKey,
|
|
123
126
|
_ref3$containerStyle = _ref3.containerStyle,
|
|
124
127
|
containerStyle = _ref3$containerStyle === void 0 ? {
|
|
125
128
|
height: '100vh'
|
|
@@ -173,11 +176,32 @@ var HireControlMap = function HireControlMap(_ref3) {
|
|
|
173
176
|
error = _useSiteConfig.error;
|
|
174
177
|
|
|
175
178
|
// Load Google Maps
|
|
176
|
-
useLoadScript({
|
|
177
|
-
googleMapsApiKey:
|
|
179
|
+
var _useLoadScript = useLoadScript({
|
|
180
|
+
googleMapsApiKey: googleMapsApiKey,
|
|
178
181
|
version: 'quarterly',
|
|
179
182
|
libraries: LIBRARIES
|
|
180
|
-
})
|
|
183
|
+
}),
|
|
184
|
+
isMapsLoaded = _useLoadScript.isLoaded,
|
|
185
|
+
loadError = _useLoadScript.loadError;
|
|
186
|
+
|
|
187
|
+
// Show loading state or error if Google Maps hasn't loaded yet
|
|
188
|
+
if (!googleMapsApiKey) {
|
|
189
|
+
console.error('Google Maps API key is required');
|
|
190
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
191
|
+
className: "hc-p-4"
|
|
192
|
+
}, "Google Maps API key is required");
|
|
193
|
+
}
|
|
194
|
+
if (loadError) {
|
|
195
|
+
console.error('Google Maps failed to load:', loadError);
|
|
196
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
197
|
+
className: "hc-p-4"
|
|
198
|
+
}, "Error loading Google Maps");
|
|
199
|
+
}
|
|
200
|
+
if (!isMapsLoaded) {
|
|
201
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
202
|
+
className: "hc-p-4"
|
|
203
|
+
}, "Loading Maps...");
|
|
204
|
+
}
|
|
181
205
|
if (error || !siteConfig) {
|
|
182
206
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
183
207
|
className: "hc-p-4"
|
|
@@ -224,7 +248,8 @@ var HireControlMap = function HireControlMap(_ref3) {
|
|
|
224
248
|
//Desktop view of filter used below
|
|
225
249
|
return /*#__PURE__*/React__default.createElement(ContextProviders, _extends({
|
|
226
250
|
siteConfig: siteConfig,
|
|
227
|
-
trackEvent: trackEvent
|
|
251
|
+
trackEvent: trackEvent,
|
|
252
|
+
googleMapsApiKey: googleMapsApiKey || process.env.GOOGLE_MAPS_API_KEY
|
|
228
253
|
}, mapListProps), /*#__PURE__*/React__default.createElement(Grid, {
|
|
229
254
|
as: "section",
|
|
230
255
|
id: "job-search-interface",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HireControlMap.js","sources":["../../src/components/HireControlMap.js"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useLoadScript } from '@react-google-maps/api';\n\nimport Grid from '~/components/modules/grid';\nimport Filter from '~/components/containers/filter/filter-container';\nimport MapList from '~/components/containers/maps/map-list-container';\n\n// Context imports\nimport { MapProvider } from '~/contexts/mapContext';\nimport { PlacesProvider } from '~/contexts/placesContext';\nimport { MapListProvider } from '~/contexts/mapListContext';\nimport { TrackEventProvider } from '~/contexts/trackEventContext';\nimport { ThemeProvider } from '~/contexts/themeContext';\n\nimport { getMapConfig } from '~/services/configService';\nimport { setClientAuthKey } from '~/clientToken.js';\n\nimport '../styles/index.css';\n\n// Libraries for Google Maps\nconst LIBRARIES = ['places'];\n\n// Custom hook to fetch site configuration\nfunction useSiteConfig(clientToken, siteConfiguration = null) {\n\tconst [siteConfig, setSiteConfig] = useState(siteConfiguration);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState(null);\n\n\tuseEffect(() => {\n\t\tconst fetchSiteConfig = async () => {\n\t\t\ttry {\n\t\t\t\tsetClientAuthKey(clientToken);\n\t\t\t\tconst configData = await getMapConfig(clientToken);\n\t\t\t\tsetSiteConfig(configData);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error('Failed to fetch site configuration:', err);\n\t\t\t\tsetError(err);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t};\n\t\tif(!siteConfig){\n\t\t\tfetchSiteConfig();\n\t\t}\n\t}, [clientToken]);\n\n\treturn { siteConfig, isLoading, error };\n}\n\n// Component to handle all context providers\nconst ContextProviders = ({ children, siteConfig, trackEvent, ...mapListProps }) => { return(\n\t<TrackEventProvider trackEvent={trackEvent}>\n\t\t<ThemeProvider\n\t\t\tuiText={siteConfig.colors.uiText}\n\t\t\tuiAccent={siteConfig.colors.uiAccent}\n\t\t\tprimary={siteConfig.colors.primary}\n\t\t\tprimaryDark={siteConfig.colors.primaryDark}\n\t\t\tsecondary={siteConfig.colors.secondary}\n\t\t\tsecondaryDark={siteConfig.colors.secondaryDark}\n\t\t>\n\t\t\t<MapListProvider siteConfig={siteConfig} {...mapListProps}>\n\t\t\t\t<MapProvider resetFilters={mapListProps.resetFilters} defaultZoomOverride={mapListProps.defaultZoomOverride}>\n\t\t\t\t\t<PlacesProvider\n\t\t\t\t\t\tplaceMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}\n\t\t\t\t\t\tadditionalMapMarkers={mapListProps.additionalMapMarkers}\n\t\t\t\t\t\tmarkerColors={{\n\t\t\t\t\t\t\tfillColor: siteConfig.colors.primary,\n\t\t\t\t\t\t\tstrokeColor: siteConfig.colors.primaryDark,\n\t\t\t\t\t\t\tselectedFillColor: siteConfig.colors.secondary,\n\t\t\t\t\t\t\tselectedStrokeColor: siteConfig.colors.secondaryDark,\n\t\t\t\t\t\t\tplaceMarkers: {\n\t\t\t\t\t\t\t\tcolors: siteConfig.pointsOfInterestConfig.placeMarkerColors,\n\t\t\t\t\t\t\t\tsize: siteConfig.pointsOfInterestConfig.placeMarkerSize\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</PlacesProvider>\n\t\t\t\t</MapProvider>\n\t\t\t</MapListProvider>\n\t\t</ThemeProvider>\n\t</TrackEventProvider>\n);};\n\n// Main component\n//\nexport const HireControlMap = ({\n\tclientToken,\n\tcontainerStyle = { height: '100vh' },\n\tnavigateToDetails = null,\n\tnavigateToEasyApply = null,\n\thandleUrlUpdate = null,\n\tLink = null,\n\tlinkFormat = '/jobs/[slug]',\n\teasyApplyUrl = null,\n\teasyApplyText = 'Easy Apply',\n\tisIframe = false,\n\ttrackEvent = (eventType, eventObj) => {\n\t\tconsole.log(eventType);\n\t\tconsole.log(eventObj);\n\t},\n\t//providing listings entities and a getListingEntities function should negate the need for map code to fetch data\n\tlistings = [],\n\tentities = [],\n\tgetListingEntitiesCallback = null,\n\tdefaultFilters = null,\n\thiddenFilters = null,\n\tsetFiltersUrl = null,\n\tExpandListComponent = null,\n\tadditionalMapMarkers = [],\n\tdefaultZoomOverride = null,\n\t//Default site configuration file passed here stops need to fetch from api\n\tsiteConfiguration = null,\n\tlocalStorageKey = 'defaultKey.'\n}) => {\n\t// Load site configuration\n\tconst { siteConfig, error } = useSiteConfig(clientToken, siteConfiguration);\n\n\t// Load Google Maps\n\tconst { isLoaded: isMapsLoaded } = useLoadScript({\n\t\tgoogleMapsApiKey: process.env.GOOGLE_MAPS_API_KEY,\n\t\tversion: 'quarterly',\n\t\tlibraries: LIBRARIES\n\t});\n\n\tif (error || !siteConfig) {\n\t\treturn <div className=\"hc-p-4\"></div>;\n\t}\n\n\t// Prepare props for MapListProvider\n\tconst mapListProps = {\n\t\tresetFilters: false,\n\t\tnavigateToDetails,\n\t\tnavigateToEasyApply,\n\t\tLink,\n\t\tlinkFormat,\n\t\teasyApplyUrl,\n\t\teasyApplyText,\n\t\tlistings,\n\t\tentities,\n\t\tsiteConfig,\n\t\tgetListingEntitiesCallback,\n\t\tsetFiltersUrl,\n\t\thiddenFilters,\n\t\thandleUrlUpdate,\n\t\tdefaultFilters,\n\t\tdefaultZoomOverride, // will usually fit bounds\n\t\tcontainerStyle,\n\t\tExpandListComponent: ExpandListComponent ?? null,\n\t\tadditionalMapMarkers,\n\t\tisIframe,\n\t\tlocalStorageKey\n\t};\n\n\t// Prepare marker configuration\n\tconst markerConfigs = {\n\t\tfillColor: siteConfig.colors.primary,\n\t\tstrokeColor: siteConfig.colors.primaryDark,\n\t\tselectedFillColor: siteConfig.colors.secondary,\n\t\tselectedStrokeColor: siteConfig.colors.secondaryDark,\n\t\tplaceMarkers: {\n\t\t\tcolors: siteConfig.pointsOfInterestConfig.placeMarkerColors,\n\t\t\tsize: siteConfig.pointsOfInterestConfig.placeMarkerSize\n\t\t}\n\t};\n\t//Desktop view of filter used below\n\treturn (\n\t\t<ContextProviders\n\t\t\tsiteConfig={siteConfig}\n\t\t\ttrackEvent={trackEvent}\n\t\t\t{...mapListProps}\n\t\t>\n\t\t\t<Grid\n\t\t\t\tas='section'\n\t\t\t\tid='job-search-interface'\n\t\t\t\tcolumns='md:hc-grid-cols-[1fr_2.5fr] lg:hc-grid-cols-[1fr_3.5fr]'\n\t\t\t\tgap='hc-gap-0'\n\t\t\t\tautoRows={false}\n\t\t\t\tclassName={'hc-bundle hc-items-stretch hc-divide-x hc-divide-uiAccent/20'}\n\t\t\t>\n\t\t\t\t<Grid.Item className='hc-bg-gray-100'>\n\t\t\t\t\t<Filter isDesktop={true} showMap={siteConfig.showMap} className='hc-hidden md:hc-block' />\n\t\t\t\t</Grid.Item>\n\t\t\t\t<MapList\n\t\t\t\t\tcontainerStyle={containerStyle}\n\t\t\t\t\tmapPosition={siteConfig.mapPosition}\n\t\t\t\t\tshowMap={siteConfig.showMap}\n\t\t\t\t\tfieldsShown={siteConfig.fieldsShown}\n\t\t\t\t\tspecialFeatures={siteConfig.specialFeatures}\n\t\t\t\t\tfieldNames={siteConfig.fieldNames}\n\t\t\t\t\tplaceMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}\n\t\t\t\t\tmarkerConfigs={markerConfigs}\n\t\t\t\t/>\n\t\t\t</Grid>\n\t\t</ContextProviders>\n\t);\n};\n\nexport default HireControlMap;\n"],"names":["LIBRARIES","useSiteConfig","clientToken","siteConfiguration","arguments","length","undefined","_useState","useState","_useState2","_slicedToArray","siteConfig","setSiteConfig","_useState3","_useState4","isLoading","setIsLoading","_useState5","_useState6","error","setError","useEffect","fetchSiteConfig","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","configData","wrap","_callee$","_context","prev","next","setClientAuthKey","getMapConfig","sent","t0","console","finish","stop","apply","ContextProviders","_ref2","_siteConfig$pointsOfI","children","trackEvent","mapListProps","_objectWithoutProperties","_excluded","React","createElement","TrackEventProvider","ThemeProvider","uiText","colors","uiAccent","primary","primaryDark","secondary","secondaryDark","MapListProvider","_extends","MapProvider","resetFilters","defaultZoomOverride","PlacesProvider","placeMappings","pointsOfInterestConfig","additionalMapMarkers","markerColors","fillColor","strokeColor","selectedFillColor","selectedStrokeColor","placeMarkers","placeMarkerColors","size","placeMarkerSize","HireControlMap","_ref3","_siteConfig$pointsOfI2","_ref3$containerStyle","containerStyle","height","_ref3$navigateToDetai","navigateToDetails","_ref3$navigateToEasyA","navigateToEasyApply","_ref3$handleUrlUpdate","handleUrlUpdate","_ref3$Link","Link","_ref3$linkFormat","linkFormat","_ref3$easyApplyUrl","easyApplyUrl","_ref3$easyApplyText","easyApplyText","_ref3$isIframe","isIframe","_ref3$trackEvent","eventType","eventObj","log","_ref3$listings","listings","_ref3$entities","entities","_ref3$getListingEntit","getListingEntitiesCallback","_ref3$defaultFilters","defaultFilters","_ref3$hiddenFilters","hiddenFilters","_ref3$setFiltersUrl","setFiltersUrl","_ref3$ExpandListCompo","ExpandListComponent","_ref3$additionalMapMa","_ref3$defaultZoomOver","_ref3$siteConfigurati","_ref3$localStorageKey","localStorageKey","_useSiteConfig","useLoadScript","googleMapsApiKey","version","libraries","className","markerConfigs","Grid","as","id","columns","gap","autoRows","Item","Filter","isDesktop","showMap","MapList","mapPosition","fieldsShown","specialFeatures","fieldNames"],"mappings":";;;;;;;;;;;;;;;;AAmBA;AACA,IAAMA,SAAS,GAAG,CAAC,QAAQ,CAAC,CAAA;;AAE5B;AACA,SAASC,aAAaA,CAACC,WAAW,EAA4B;AAAA,EAAA,IAA1BC,iBAAiB,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,IAAI,CAAA;AAC3D,EAAA,IAAAG,SAAA,GAAoCC,QAAQ,CAACL,iBAAiB,CAAC;IAAAM,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAxDI,IAAAA,UAAU,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,aAAa,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;AAChC,EAAA,IAAAI,UAAA,GAAkCL,QAAQ,CAAC,IAAI,CAAC;IAAAM,UAAA,GAAAJ,cAAA,CAAAG,UAAA,EAAA,CAAA,CAAA;AAAzCE,IAAAA,SAAS,GAAAD,UAAA,CAAA,CAAA,CAAA;AAAEE,IAAAA,YAAY,GAAAF,UAAA,CAAA,CAAA,CAAA,CAAA;AAC9B,EAAA,IAAAG,UAAA,GAA0BT,QAAQ,CAAC,IAAI,CAAC;IAAAU,UAAA,GAAAR,cAAA,CAAAO,UAAA,EAAA,CAAA,CAAA;AAAjCE,IAAAA,KAAK,GAAAD,UAAA,CAAA,CAAA,CAAA;AAAEE,IAAAA,QAAQ,GAAAF,UAAA,CAAA,CAAA,CAAA,CAAA;AAEt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"file":"HireControlMap.js","sources":["../../src/components/HireControlMap.js"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useLoadScript } from '@react-google-maps/api';\n\nimport Grid from '~/components/modules/grid';\nimport Filter from '~/components/containers/filter/filter-container';\nimport MapList from '~/components/containers/maps/map-list-container';\n\n// Context imports\nimport { MapProvider } from '~/contexts/mapContext';\nimport { PlacesProvider } from '~/contexts/placesContext';\nimport { MapListProvider } from '~/contexts/mapListContext';\nimport { TrackEventProvider } from '~/contexts/trackEventContext';\nimport { ThemeProvider } from '~/contexts/themeContext';\n\nimport { getMapConfig } from '~/services/configService';\nimport { setClientAuthKey } from '~/clientToken.js';\n\nimport '../styles/index.css';\n\n// Libraries for Google Maps\nconst LIBRARIES = ['places'];\n\n// Custom hook to fetch site configuration\nfunction useSiteConfig(clientToken, siteConfiguration = null) {\n\tconst [siteConfig, setSiteConfig] = useState(siteConfiguration);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState(null);\n\n\tuseEffect(() => {\n\t\tconst fetchSiteConfig = async () => {\n\t\t\ttry {\n\t\t\t\tsetClientAuthKey(clientToken);\n\t\t\t\tconst configData = await getMapConfig(clientToken);\n\t\t\t\tsetSiteConfig(configData);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error('Failed to fetch site configuration:', err);\n\t\t\t\tsetError(err);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t};\n\t\tif(!siteConfig){\n\t\t\tfetchSiteConfig();\n\t\t}\n\t}, [clientToken]);\n\n\treturn { siteConfig, isLoading, error };\n}\n\n// Component to handle all context providers\nconst ContextProviders = ({ children, siteConfig, trackEvent, googleMapsApiKey, ...mapListProps }) => { return(\n\t<TrackEventProvider trackEvent={trackEvent}>\n\t\t<ThemeProvider\n\t\t\tuiText={siteConfig.colors.uiText}\n\t\t\tuiAccent={siteConfig.colors.uiAccent}\n\t\t\tprimary={siteConfig.colors.primary}\n\t\t\tprimaryDark={siteConfig.colors.primaryDark}\n\t\t\tsecondary={siteConfig.colors.secondary}\n\t\t\tsecondaryDark={siteConfig.colors.secondaryDark}\n\t\t>\n\t\t\t<MapListProvider siteConfig={siteConfig} {...mapListProps}>\n\t\t\t\t<MapProvider resetFilters={mapListProps.resetFilters} defaultZoomOverride={mapListProps.defaultZoomOverride}>\n\t\t\t\t\t<PlacesProvider\n\t\t\t\t\t\tplaceMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}\n\t\t\t\t\t\tadditionalMapMarkers={mapListProps.additionalMapMarkers}\n\t\t\t\t\t\tgoogleMapsApiKey={googleMapsApiKey}\n\t\t\t\t\t\tmarkerColors={{\n\t\t\t\t\t\t\tfillColor: siteConfig.colors.primary,\n\t\t\t\t\t\t\tstrokeColor: siteConfig.colors.primaryDark,\n\t\t\t\t\t\t\tselectedFillColor: siteConfig.colors.secondary,\n\t\t\t\t\t\t\tselectedStrokeColor: siteConfig.colors.secondaryDark,\n\t\t\t\t\t\t\tplaceMarkers: {\n\t\t\t\t\t\t\t\tcolors: siteConfig.pointsOfInterestConfig.placeMarkerColors,\n\t\t\t\t\t\t\t\tsize: siteConfig.pointsOfInterestConfig.placeMarkerSize\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</PlacesProvider>\n\t\t\t\t</MapProvider>\n\t\t\t</MapListProvider>\n\t\t</ThemeProvider>\n\t</TrackEventProvider>\n);};\n\n// Main component\n//\nexport const HireControlMap = ({\n\tclientToken,\n\tgoogleMapsApiKey, // Required: Google Maps API key from Next.js\n\tcontainerStyle = { height: '100vh' },\n\tnavigateToDetails = null,\n\tnavigateToEasyApply = null,\n\thandleUrlUpdate = null,\n\tLink = null,\n\tlinkFormat = '/jobs/[slug]',\n\teasyApplyUrl = null,\n\teasyApplyText = 'Easy Apply',\n\tisIframe = false,\n\ttrackEvent = (eventType, eventObj) => {\n\t\tconsole.log(eventType);\n\t\tconsole.log(eventObj);\n\t},\n\t//providing listings entities and a getListingEntities function should negate the need for map code to fetch data\n\tlistings = [],\n\tentities = [],\n\tgetListingEntitiesCallback = null,\n\tdefaultFilters = null,\n\thiddenFilters = null,\n\tsetFiltersUrl = null,\n\tExpandListComponent = null,\n\tadditionalMapMarkers = [],\n\tdefaultZoomOverride = null,\n\t//Default site configuration file passed here stops need to fetch from api\n\tsiteConfiguration = null,\n\tlocalStorageKey = 'defaultKey.'\n}) => {\n\t// Load site configuration\n\tconst { siteConfig, error } = useSiteConfig(clientToken, siteConfiguration);\n\n\t// Load Google Maps\n\tconst { isLoaded: isMapsLoaded, loadError } = useLoadScript({\n\t\tgoogleMapsApiKey: googleMapsApiKey,\n\t\tversion: 'quarterly',\n\t\tlibraries: LIBRARIES\n\t});\n\n\t// Show loading state or error if Google Maps hasn't loaded yet\n\tif (!googleMapsApiKey) {\n\t\tconsole.error('Google Maps API key is required');\n\t\treturn <div className=\"hc-p-4\">Google Maps API key is required</div>;\n\t}\n\n\tif (loadError) {\n\t\tconsole.error('Google Maps failed to load:', loadError);\n\t\treturn <div className=\"hc-p-4\">Error loading Google Maps</div>;\n\t}\n\n\tif (!isMapsLoaded) {\n\t\treturn <div className=\"hc-p-4\">Loading Maps...</div>;\n\t}\n\n\tif (error || !siteConfig) {\n\t\treturn <div className=\"hc-p-4\"></div>;\n\t}\n\n\t// Prepare props for MapListProvider\n\tconst mapListProps = {\n\t\tresetFilters: false,\n\t\tnavigateToDetails,\n\t\tnavigateToEasyApply,\n\t\tLink,\n\t\tlinkFormat,\n\t\teasyApplyUrl,\n\t\teasyApplyText,\n\t\tlistings,\n\t\tentities,\n\t\tsiteConfig,\n\t\tgetListingEntitiesCallback,\n\t\tsetFiltersUrl,\n\t\thiddenFilters,\n\t\thandleUrlUpdate,\n\t\tdefaultFilters,\n\t\tdefaultZoomOverride, // will usually fit bounds\n\t\tcontainerStyle,\n\t\tExpandListComponent: ExpandListComponent ?? null,\n\t\tadditionalMapMarkers,\n\t\tisIframe,\n\t\tlocalStorageKey\n\t};\n\n\t// Prepare marker configuration\n\tconst markerConfigs = {\n\t\tfillColor: siteConfig.colors.primary,\n\t\tstrokeColor: siteConfig.colors.primaryDark,\n\t\tselectedFillColor: siteConfig.colors.secondary,\n\t\tselectedStrokeColor: siteConfig.colors.secondaryDark,\n\t\tplaceMarkers: {\n\t\t\tcolors: siteConfig.pointsOfInterestConfig.placeMarkerColors,\n\t\t\tsize: siteConfig.pointsOfInterestConfig.placeMarkerSize\n\t\t}\n\t};\n\t//Desktop view of filter used below\n\treturn (\n\t\t<ContextProviders\n\t\t\tsiteConfig={siteConfig}\n\t\t\ttrackEvent={trackEvent}\n\t\t\tgoogleMapsApiKey={googleMapsApiKey || process.env.GOOGLE_MAPS_API_KEY}\n\t\t\t{...mapListProps}\n\t\t>\n\t\t\t<Grid\n\t\t\t\tas='section'\n\t\t\t\tid='job-search-interface'\n\t\t\t\tcolumns='md:hc-grid-cols-[1fr_2.5fr] lg:hc-grid-cols-[1fr_3.5fr]'\n\t\t\t\tgap='hc-gap-0'\n\t\t\t\tautoRows={false}\n\t\t\t\tclassName={'hc-bundle hc-items-stretch hc-divide-x hc-divide-uiAccent/20'}\n\t\t\t>\n\t\t\t\t<Grid.Item className='hc-bg-gray-100'>\n\t\t\t\t\t<Filter isDesktop={true} showMap={siteConfig.showMap} className='hc-hidden md:hc-block' />\n\t\t\t\t</Grid.Item>\n\t\t\t\t<MapList\n\t\t\t\t\tcontainerStyle={containerStyle}\n\t\t\t\t\tmapPosition={siteConfig.mapPosition}\n\t\t\t\t\tshowMap={siteConfig.showMap}\n\t\t\t\t\tfieldsShown={siteConfig.fieldsShown}\n\t\t\t\t\tspecialFeatures={siteConfig.specialFeatures}\n\t\t\t\t\tfieldNames={siteConfig.fieldNames}\n\t\t\t\t\tplaceMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}\n\t\t\t\t\tmarkerConfigs={markerConfigs}\n\t\t\t\t/>\n\t\t\t</Grid>\n\t\t</ContextProviders>\n\t);\n};\n\nexport default HireControlMap;\n"],"names":["LIBRARIES","useSiteConfig","clientToken","siteConfiguration","arguments","length","undefined","_useState","useState","_useState2","_slicedToArray","siteConfig","setSiteConfig","_useState3","_useState4","isLoading","setIsLoading","_useState5","_useState6","error","setError","useEffect","fetchSiteConfig","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","configData","wrap","_callee$","_context","prev","next","setClientAuthKey","getMapConfig","sent","t0","console","finish","stop","apply","ContextProviders","_ref2","_siteConfig$pointsOfI","children","trackEvent","googleMapsApiKey","mapListProps","_objectWithoutProperties","_excluded","React","createElement","TrackEventProvider","ThemeProvider","uiText","colors","uiAccent","primary","primaryDark","secondary","secondaryDark","MapListProvider","_extends","MapProvider","resetFilters","defaultZoomOverride","PlacesProvider","placeMappings","pointsOfInterestConfig","additionalMapMarkers","markerColors","fillColor","strokeColor","selectedFillColor","selectedStrokeColor","placeMarkers","placeMarkerColors","size","placeMarkerSize","HireControlMap","_ref3","_siteConfig$pointsOfI2","_ref3$containerStyle","containerStyle","height","_ref3$navigateToDetai","navigateToDetails","_ref3$navigateToEasyA","navigateToEasyApply","_ref3$handleUrlUpdate","handleUrlUpdate","_ref3$Link","Link","_ref3$linkFormat","linkFormat","_ref3$easyApplyUrl","easyApplyUrl","_ref3$easyApplyText","easyApplyText","_ref3$isIframe","isIframe","_ref3$trackEvent","eventType","eventObj","log","_ref3$listings","listings","_ref3$entities","entities","_ref3$getListingEntit","getListingEntitiesCallback","_ref3$defaultFilters","defaultFilters","_ref3$hiddenFilters","hiddenFilters","_ref3$setFiltersUrl","setFiltersUrl","_ref3$ExpandListCompo","ExpandListComponent","_ref3$additionalMapMa","_ref3$defaultZoomOver","_ref3$siteConfigurati","_ref3$localStorageKey","localStorageKey","_useSiteConfig","_useLoadScript","useLoadScript","version","libraries","isMapsLoaded","isLoaded","loadError","className","markerConfigs","process","env","GOOGLE_MAPS_API_KEY","Grid","as","id","columns","gap","autoRows","Item","Fil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I,CAACM,IAAI,EAAA;AAACX,IAAAA,SAAS,EAAC,gBAAA;AAAgB,GAAA,eACpClF,cAAA,CAAAC,aAAA,CAAC6F,eAAM,EAAA;AAACC,IAAAA,SAAS,EAAE,IAAK;IAACC,OAAO,EAAExI,UAAU,CAACwI,OAAQ;AAACd,IAAAA,SAAS,EAAC,uBAAA;AAAuB,GAAE,CAC/E,CAAC,eACZlF,cAAA,CAAAC,aAAA,CAACgG,gBAAO,EAAA;AACPhE,IAAAA,cAAc,EAAEA,cAAe;IAC/BiE,WAAW,EAAE1I,UAAU,CAAC0I,WAAY;IACpCF,OAAO,EAAExI,UAAU,CAACwI,OAAQ;IAC5BG,WAAW,EAAE3I,UAAU,CAAC2I,WAAY;IACpCC,eAAe,EAAE5I,UAAU,CAAC4I,eAAgB;IAC5CC,UAAU,EAAE7I,UAAU,CAAC6I,UAAW;AAClCpF,IAAAA,aAAa,EAAAc,CAAAA,sBAAA,GAAEvE,UAAU,CAAC0D,sBAAsB,CAACD,aAAa,MAAA,IAAA,IAAAc,sBAAA,KAAA,KAAA,CAAA,GAAAA,sBAAA,GAAI,EAAG;AACrEoD,IAAAA,aAAa,EAAEA,aAAAA;GACf,CACI,CACW,CAAC,CAAA;AAErB;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime, createForOfIteratorHelper as _createForOfIteratorHelper } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React__default, { useState, useEffect, createContext, useContext } from 'react';
|
|
2
|
+
import React__default, { useState, useCallback, useEffect, createContext, useContext } from 'react';
|
|
3
3
|
import { markerIconProps } from '../util/mapIconUtil.js';
|
|
4
4
|
import { useMap } from './mapContext.js';
|
|
5
5
|
import { searchNearbyPlaces } from '../services/googlePlacesNearbyService.js';
|
|
@@ -12,7 +12,8 @@ var PlacesProvider = function PlacesProvider(_ref) {
|
|
|
12
12
|
var children = _ref.children,
|
|
13
13
|
placeMappings = _ref.placeMappings,
|
|
14
14
|
markerColors = _ref.markerColors,
|
|
15
|
-
additionalMapMarkers = _ref.additionalMapMarkers
|
|
15
|
+
additionalMapMarkers = _ref.additionalMapMarkers,
|
|
16
|
+
googleMapsApiKey = _ref.googleMapsApiKey;
|
|
16
17
|
var _useMap = useMap(),
|
|
17
18
|
selectedPlaces = _useMap.selectedPlaces,
|
|
18
19
|
zoom = _useMap.zoom,
|
|
@@ -40,7 +41,7 @@ var PlacesProvider = function PlacesProvider(_ref) {
|
|
|
40
41
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
41
42
|
selectedPlaceMarker = _useState10[0],
|
|
42
43
|
setSelectedPlaceMarker = _useState10[1];
|
|
43
|
-
var getRadiusForZoom = function
|
|
44
|
+
var getRadiusForZoom = useCallback(function () {
|
|
44
45
|
if (currentZoom >= 18) return 1000;
|
|
45
46
|
if (currentZoom <= 10) return 0;
|
|
46
47
|
var tempZoom = Math.pow(19 - currentZoom, 4.85);
|
|
@@ -49,7 +50,7 @@ var PlacesProvider = function PlacesProvider(_ref) {
|
|
|
49
50
|
var maxRadius = 800000;
|
|
50
51
|
if (radius < minRadius) radius = minRadius;else if (radius > maxRadius) radius = maxRadius;
|
|
51
52
|
return radius;
|
|
52
|
-
};
|
|
53
|
+
}, [currentZoom]);
|
|
53
54
|
useEffect(function () {
|
|
54
55
|
if (!selectedPlaces || !selectedPlaces.length > 0 || !center || currentZoom < 12) {
|
|
55
56
|
setPoiMarkers({
|
|
@@ -76,7 +77,7 @@ var PlacesProvider = function PlacesProvider(_ref) {
|
|
|
76
77
|
};
|
|
77
78
|
_context.prev = 5;
|
|
78
79
|
_context.next = 8;
|
|
79
|
-
return searchNearbyPlaces(poiTypes, location, radius);
|
|
80
|
+
return searchNearbyPlaces(poiTypes, location, radius, googleMapsApiKey || process.env.GOOGLE_MAPS_API_KEY);
|
|
80
81
|
case 8:
|
|
81
82
|
response = _context.sent;
|
|
82
83
|
newMarkers = response.places.map(function (place) {
|
|
@@ -133,7 +134,7 @@ var PlacesProvider = function PlacesProvider(_ref) {
|
|
|
133
134
|
};
|
|
134
135
|
}();
|
|
135
136
|
fetchPlaces();
|
|
136
|
-
}, [selectedPlaces, currentZoom, currentCenter]);
|
|
137
|
+
}, [selectedPlaces, currentZoom, currentCenter, placeMappings, markerColors.placeMarkers, googleMapsApiKey, getRadiusForZoom, center]);
|
|
137
138
|
return /*#__PURE__*/React__default.createElement(PlacesContext.Provider, {
|
|
138
139
|
value: {
|
|
139
140
|
poiMarkers: poiMarkers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placesContext.js","sources":["../../src/contexts/placesContext.js"],"sourcesContent":["import React, { createContext, useContext, useEffect, useState } from 'react';\n\nimport { markerIconProps } from '~/util/mapIconUtil';\n\nimport { useMap } from '~/contexts/mapContext';\n\nimport { searchNearbyPlaces } from '~/services/googlePlacesNearbyService';\n\nconst PlacesContext = createContext();\n\nexport const usePlaces = () => useContext(PlacesContext);\n\nexport const PlacesProvider = ({ children, placeMappings, markerColors, additionalMapMarkers }) => {\n\tconst { selectedPlaces, zoom, center } = useMap();\n\tconst [poiMarkers, setPoiMarkers] = useState({ markers: [], icon: null });\n\tconst [currentCenter, setCurrentCenter] = useState(center);\n\tconst [currentZoom, setCurrentZoom] = useState(zoom);\n\tconst [placesWindow, setPlacesWindow] = useState(false);\n\tconst [selectedPlaceMarker, setSelectedPlaceMarker] = useState(null);\n\n\tconst getRadiusForZoom = () => {\n\t\tif (currentZoom >= 18) return 1000;\n\t\tif (currentZoom <= 10) return 0;\n\n\t\tlet tempZoom = Math.pow(19 - currentZoom, 4.85);\n\t\tlet radius = tempZoom;\n\t\tlet minRadius = 1500;\n\t\tlet maxRadius = 800000;\n\n\t\tif (radius < minRadius) radius = minRadius;\n\t\telse if (radius > maxRadius) radius = maxRadius;\n\n\t\treturn radius;\n\t};\n\n\tuseEffect(() => {\n\t\tif (!selectedPlaces || (!selectedPlaces.length > 0) || !center || currentZoom < 12) {\n\t\t\tsetPoiMarkers({ markers: [], icon: null });\n\t\t\treturn;\n\t\t}\n\t\tconst fetchPlaces = async () => {\n\t\t\tlet poiTypes = [];\n\t\t\tconst selectedPOICategories = selectedPlaces;\n\t\t\tselectedPOICategories.forEach(pointOfInterest => {\n\t\t\t\tpoiTypes = poiTypes.concat(placeMappings[pointOfInterest]);\n\t\t\t});\n\n\t\t\tconst radius = getRadiusForZoom();\n\t\t\tconst location = { latitude: currentCenter.lat, longitude: currentCenter.lng };\n\n\t\t\ttry {\n\t\t\t\tconst response = await searchNearbyPlaces(poiTypes, location, radius);\n\t\t\t\tconst newMarkers = response.places.map(place => {\n\t\t\t\t\tconst getParentCategory = types => {\n\t\t\t\t\t\tconst selectedTypes = selectedPOICategories.reduce((acc, category) => {\n\t\t\t\t\t\t\treturn acc.concat(placeMappings[category]);\n\t\t\t\t\t\t}, []);\n\n\t\t\t\t\t\tfor (const type of types) {\n\t\t\t\t\t\t\tif (!selectedTypes.includes(type)) continue;\n\t\t\t\t\t\t\tfor (const category in placeMappings) {\n\t\t\t\t\t\t\t\tif (placeMappings[category].includes(type)) {\n\t\t\t\t\t\t\t\t\treturn category;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tconst icon = markerIconProps(markerColors.placeMarkers, getParentCategory(place.types));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tposition: { lat: place.location.latitude, lng: place.location.longitude },\n\t\t\t\t\t\ttitle: place.displayName.text,\n\t\t\t\t\t\ticon: icon\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t\tsetPoiMarkers({ markers: newMarkers, icon: null });\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Failed to fetch places:', error);\n\t\t\t}\n\t\t};\n\n\t\tfetchPlaces();\n\t}, [selectedPlaces, currentZoom, currentCenter]);\n\n\treturn (\n\t\t<PlacesContext.Provider value={{\n\t\t\tpoiMarkers,\n\t\t\tsetCurrentCenter,\n\t\t\tcurrentCenter,\n\t\t\tsetCurrentZoom,\n\t\t\tcurrentZoom,\n\t\t\tplacesWindow,\n\t\t\tsetPlacesWindow,\n\t\t\tselectedPlaceMarker,\n\t\t\tsetSelectedPlaceMarker,\n\t\t\tadditionalMapMarkers\n\t\t}}>\n\t\t\t{children}\n\t\t</PlacesContext.Provider>\n\t);\n};\n"],"names":["PlacesContext","createContext","usePlaces","useContext","PlacesProvider","_ref","children","placeMappings","markerColors","additionalMapMarkers","_useMap","useMap","selectedPlaces","zoom","center","_useState","useState","markers","icon","_useState2","_slicedToArray","poiMarkers","setPoiMarkers","_useState3","_useState4","currentCenter","setCurrentCenter","_useState5","_useState6","currentZoom","setCurrentZoom","_useState7","_useState8","placesWindow","setPlacesWindow","_useState9","_useState10","selectedPlaceMarker","setSelectedPlaceMarker","getRadiusForZoom","tempZoom","Math","pow","radius","minRadius","maxRadius","useEffect","length","fetchPlaces","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","poiTypes","selectedPOICategories","location","response","newMarkers","wrap","_callee$","_context","prev","next","forEach","pointOfInterest","concat","latitude","lat","longitude","lng","searchNearbyPlaces","sent","places","map","place","getParentCategory","types","selectedTypes","reduce","acc","category","_iterator","_createForOfIteratorHelper","_step","s","n","done","type","value","includes","err","e","f","markerIconProps","placeMarkers","position","title","displayName","text","t0","console","error","stop","apply","arguments","React","createElement","Provider"],"mappings":";;;;;;AAQA,IAAMA,aAAa,gBAAGC,aAAa,EAAE,CAAA;AAExBC,IAAAA,SAAS,GAAG,SAAZA,SAASA,GAAA;EAAA,OAASC,UAAU,CAACH,aAAa,CAAC,CAAA;AAAA,EAAA;IAE3CI,cAAc,GAAG,SAAjBA,cAAcA,CAAAC,IAAA,EAAwE;AAAA,EAAA,IAAlEC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,aAAa,GAAAF,IAAA,CAAbE,aAAa;IAAEC,YAAY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,MAAAA,WAAW,EAAXA,WAAW;AACXI,MAAAA,YAAY,EAAZA,YAAY;AACZC,MAAAA,eAAe,EAAfA,eAAe;AACfG,MAAAA,mBAAmB,EAAnBA,mBAAmB;AACnBC,MAAAA,sBAAsB,EAAtBA,sBAAsB;AACtB7B,MAAAA,oBAAoB,EAApBA,oBAAAA;AACD,KAAA;AAAE,GAAA,EACAH,QACsB,CAAC,CAAA;AAE3B;;;;"}
|
|
1
|
+
{"version":3,"file":"placesContext.js","sources":["../../src/contexts/placesContext.js"],"sourcesContent":["import React, { createContext, useContext, useEffect, useState, useCallback } from 'react';\n\nimport { markerIconProps } from '~/util/mapIconUtil';\n\nimport { useMap } from '~/contexts/mapContext';\n\nimport { searchNearbyPlaces } from '~/services/googlePlacesNearbyService';\n\nconst PlacesContext = createContext();\n\nexport const usePlaces = () => useContext(PlacesContext);\n\nexport const PlacesProvider = ({ children, placeMappings, markerColors, additionalMapMarkers, googleMapsApiKey }) => {\n\tconst { selectedPlaces, zoom, center } = useMap();\n\tconst [poiMarkers, setPoiMarkers] = useState({ markers: [], icon: null });\n\tconst [currentCenter, setCurrentCenter] = useState(center);\n\tconst [currentZoom, setCurrentZoom] = useState(zoom);\n\tconst [placesWindow, setPlacesWindow] = useState(false);\n\tconst [selectedPlaceMarker, setSelectedPlaceMarker] = useState(null);\n\n\tconst getRadiusForZoom = useCallback(() => {\n\t\tif (currentZoom >= 18) return 1000;\n\t\tif (currentZoom <= 10) return 0;\n\n\t\tlet tempZoom = Math.pow(19 - currentZoom, 4.85);\n\t\tlet radius = tempZoom;\n\t\tlet minRadius = 1500;\n\t\tlet maxRadius = 800000;\n\n\t\tif (radius < minRadius) radius = minRadius;\n\t\telse if (radius > maxRadius) radius = maxRadius;\n\n\t\treturn radius;\n\t}, [currentZoom]);\n\n\tuseEffect(() => {\n\t\tif (!selectedPlaces || (!selectedPlaces.length > 0) || !center || currentZoom < 12) {\n\t\t\tsetPoiMarkers({ markers: [], icon: null });\n\t\t\treturn;\n\t\t}\n\t\tconst fetchPlaces = async () => {\n\t\t\tlet poiTypes = [];\n\t\t\tconst selectedPOICategories = selectedPlaces;\n\t\t\tselectedPOICategories.forEach(pointOfInterest => {\n\t\t\t\tpoiTypes = poiTypes.concat(placeMappings[pointOfInterest]);\n\t\t\t});\n\n\t\t\tconst radius = getRadiusForZoom();\n\t\t\tconst location = { latitude: currentCenter.lat, longitude: currentCenter.lng };\n\n\t\t\ttry {\n\t\t\t\tconst response = await searchNearbyPlaces(poiTypes, location, radius, googleMapsApiKey || process.env.GOOGLE_MAPS_API_KEY);\n\t\t\t\tconst newMarkers = response.places.map(place => {\n\t\t\t\t\tconst getParentCategory = types => {\n\t\t\t\t\t\tconst selectedTypes = selectedPOICategories.reduce((acc, category) => {\n\t\t\t\t\t\t\treturn acc.concat(placeMappings[category]);\n\t\t\t\t\t\t}, []);\n\n\t\t\t\t\t\tfor (const type of types) {\n\t\t\t\t\t\t\tif (!selectedTypes.includes(type)) continue;\n\t\t\t\t\t\t\tfor (const category in placeMappings) {\n\t\t\t\t\t\t\t\tif (placeMappings[category].includes(type)) {\n\t\t\t\t\t\t\t\t\treturn category;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tconst icon = markerIconProps(markerColors.placeMarkers, getParentCategory(place.types));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tposition: { lat: place.location.latitude, lng: place.location.longitude },\n\t\t\t\t\t\ttitle: place.displayName.text,\n\t\t\t\t\t\ticon: icon\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t\tsetPoiMarkers({ markers: newMarkers, icon: null });\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Failed to fetch places:', error);\n\t\t\t}\n\t\t};\n\n\t\tfetchPlaces();\n\t}, [selectedPlaces, currentZoom, currentCenter, placeMappings, markerColors.placeMarkers, googleMapsApiKey, getRadiusForZoom, center]);\n\n\treturn (\n\t\t<PlacesContext.Provider value={{\n\t\t\tpoiMarkers,\n\t\t\tsetCurrentCenter,\n\t\t\tcurrentCenter,\n\t\t\tsetCurrentZoom,\n\t\t\tcurrentZoom,\n\t\t\tplacesWindow,\n\t\t\tsetPlacesWindow,\n\t\t\tselectedPlaceMarker,\n\t\t\tsetSelectedPlaceMarker,\n\t\t\tadditionalMapMarkers\n\t\t}}>\n\t\t\t{children}\n\t\t</PlacesContext.Provider>\n\t);\n};\n"],"names":["PlacesContext","createContext","usePlaces","useContext","PlacesProvider","_ref","children","placeMappings","markerColors","additionalMapMarkers","googleMapsApiKey","_useMap","useMap","selectedPlaces","zoom","center","_useState","useState","markers","icon","_useState2","_slicedToArray","poiMarkers","setPoiMarkers","_useState3","_useState4","currentCenter","setCurrentCenter","_useState5","_useState6","currentZoom","setCurrentZoom","_useState7","_useState8","placesWindow","setPlacesWindow","_useState9","_useState10","selectedPlaceMarker","setSelectedPlaceMarker","getRadiusForZoom","useCallback","tempZoom","Math","pow","radius","minRadius","maxRadius","useEffect","length","fetchPlaces","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","poiTypes","selectedPOICategories","location","response","newMarkers","wrap","_callee$","_context","prev","next","forEach","pointOfInterest","concat","latitude","lat","longitude","lng","searchNearbyPlaces","process","env","GOOGLE_MAPS_API_KEY","sent","places","map","place","getParentCategory","types","selectedTypes","reduce","acc","category","_iterator","_createForOfIteratorHelper","_step","s","n","done","type","value","includes","err","e","f","markerIconProps","placeMarkers","position","title","displayName","text","t0","console","error","stop","apply","arguments","React","createElement","Provider"],"mappings":";;;;;;AAQA,IAAMA,aAAa,gBAAGC,aAAa,EAAE,CAAA;AAExBC,IAAAA,SAAS,GAAG,SAAZA,SAASA,GAAA;EAAA,OAASC,UAAU,CAACH,aAAa,CAAC,CAAA;AAAA,EAAA;IAE3CI,cAAc,GAAG,SAAjBA,cAAcA,CAAAC,IAAA,EAA0F;AAAA,EAAA,IAApFC,QAAQ,GAAAD,IAAA,CAARC,QAA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AgB,EAAEzB,MAAM,CAAC,CAAC,CAAA;AAEtI,EAAA,oBACCgG,cAAA,CAAAC,aAAA,CAAChH,aAAa,CAACiH,QAAQ,EAAA;AAACnB,IAAAA,KAAK,EAAE;AAC9BxE,MAAAA,UAAU,EAAVA,UAAU;AACVK,MAAAA,gBAAgB,EAAhBA,gBAAgB;AAChBD,MAAAA,aAAa,EAAbA,aAAa;AACbK,MAAAA,cAAc,EAAdA,cAAc;AACdD,MAAAA,WAAW,EAAXA,WAAW;AACXI,MAAAA,YAAY,EAAZA,YAAY;AACZC,MAAAA,eAAe,EAAfA,eAAe;AACfG,MAAAA,mBAAmB,EAAnBA,mBAAmB;AACnBC,MAAAA,sBAAsB,EAAtBA,sBAAsB;AACtB9B,MAAAA,oBAAoB,EAApBA,oBAAAA;AACD,KAAA;AAAE,GAAA,EACAH,QACsB,CAAC,CAAA;AAE3B;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const searchNearbyPlaces = async (typesArray, location, radius) => {
|
|
1
|
+
const searchNearbyPlaces = async (typesArray, location, radius, apiKey) => {
|
|
2
2
|
const url = 'https://places.googleapis.com/v1/places:searchNearby';
|
|
3
3
|
const headers = {
|
|
4
4
|
'Content-Type': 'application/json',
|
|
5
|
-
'X-Goog-Api-Key':
|
|
5
|
+
'X-Goog-Api-Key': apiKey || process.env.GOOGLE_MAPS_API_KEY,
|
|
6
6
|
'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
|
|
7
7
|
};
|
|
8
8
|
const data = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"googlePlacesNearbyService.js","sources":["../../src/services/googlePlacesNearbyService.ts"],"sourcesContent":["export interface Location {\n\tlatitude: number;\n\tlongitude: number;\n}\n\nexport const searchNearbyPlaces = async (\n\ttypesArray: string[],\n\tlocation: Location,\n\tradius: number\n): Promise<any> => {\n\tconst url = 'https://places.googleapis.com/v1/places:searchNearby';\n\tconst headers = {\n\t\t'Content-Type': 'application/json',\n\t\t'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY as string,\n\t\t'X-Goog-FieldMask': 'places.location,places.displayName,places.types'\n\t};\n\tconst data = {\n\t\tincludedTypes: typesArray,\n\t\tmaxResultCount: 20,\n\t\tlocationRestriction: {\n\t\t\tcircle: {\n\t\t\t\tcenter: location,\n\t\t\t\tradius: radius\n\t\t\t}\n\t\t}\n\t};\n\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify(data)\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`HTTP error! status: ${response.status}`);\n\t\t}\n\t\treturn await response.json();\n\t} catch (error) {\n\t\tconsole.error('Error making the Nearby Search request:', error);\n\t\tthrow error;\n\t}\n};\n"],"names":[],"mappings":"AAKO,MAAM,kBAAkB,GAAG,OACjC,UAAoB,EACpB,QAAkB,EAClB,MAAc,
|
|
1
|
+
{"version":3,"file":"googlePlacesNearbyService.js","sources":["../../src/services/googlePlacesNearbyService.ts"],"sourcesContent":["export interface Location {\n\tlatitude: number;\n\tlongitude: number;\n}\n\nexport const searchNearbyPlaces = async (\n\ttypesArray: string[],\n\tlocation: Location,\n\tradius: number,\n\tapiKey?: string\n): Promise<any> => {\n\tconst url = 'https://places.googleapis.com/v1/places:searchNearby';\n\tconst headers = {\n\t\t'Content-Type': 'application/json',\n\t\t'X-Goog-Api-Key': apiKey || (process.env.GOOGLE_MAPS_API_KEY as string),\n\t\t'X-Goog-FieldMask': 'places.location,places.displayName,places.types'\n\t};\n\tconst data = {\n\t\tincludedTypes: typesArray,\n\t\tmaxResultCount: 20,\n\t\tlocationRestriction: {\n\t\t\tcircle: {\n\t\t\t\tcenter: location,\n\t\t\t\tradius: radius\n\t\t\t}\n\t\t}\n\t};\n\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify(data)\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`HTTP error! status: ${response.status}`);\n\t\t}\n\t\treturn await response.json();\n\t} catch (error) {\n\t\tconsole.error('Error making the Nearby Search request:', error);\n\t\tthrow error;\n\t}\n};\n"],"names":[],"mappings":"AAKO,MAAM,kBAAkB,GAAG,OACjC,UAAoB,EACpB,QAAkB,EAClB,MAAc,EACd,MAAe,KACE;IACjB,MAAM,GAAG,GAAG,sDAAsD,CAAC;AACnE,IAAA,MAAM,OAAO,GAAG;AACf,QAAA,cAAc,EAAE,kBAAkB;AAClC,QAAA,gBAAgB,EAAE,MAAM,IAAK,OAAO,CAAC,GAAG,CAAC,mBAA8B;AACvE,QAAA,kBAAkB,EAAE,iDAAiD;KACrE,CAAC;AACF,IAAA,MAAM,IAAI,GAAG;AACZ,QAAA,aAAa,EAAE,UAAU;AACzB,QAAA,cAAc,EAAE,EAAE;AAClB,QAAA,mBAAmB,EAAE;AACpB,YAAA,MAAM,EAAE;AACP,gBAAA,MAAM,EAAE,QAAQ;AAChB,gBAAA,MAAM,EAAE,MAAM;AACd,aAAA;AACD,SAAA;KACD,CAAC;IAEF,IAAI;AACH,QAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AACjC,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAC1B,SAAA,CAAC,CAAC;AACH,QAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,CAAA,oBAAA,EAAuB,QAAQ,CAAC,MAAM,CAAE,CAAA,CAAC,CAAC;AAC1D,SAAA;AACD,QAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC7B,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACf,QAAA,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;AAChE,QAAA,MAAM,KAAK,CAAC;AACZ,KAAA;AACF;;;;"}
|
|
@@ -2,4 +2,4 @@ export interface Location {
|
|
|
2
2
|
latitude: number;
|
|
3
3
|
longitude: number;
|
|
4
4
|
}
|
|
5
|
-
export declare const searchNearbyPlaces: (typesArray: string[], location: Location, radius: number) => Promise<any>;
|
|
5
|
+
export declare const searchNearbyPlaces: (typesArray: string[], location: Location, radius: number, apiKey?: string) => Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abcagency/hc-ui-components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.9",
|
|
4
4
|
"description": "UI Components for HireControl",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "cross-env NODE_ENV=production rollup -c",
|
|
12
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"prepublishOnly": "npm run build",
|
|
14
|
+
"release:patch": "npm version patch && npm run build && npm publish",
|
|
15
|
+
"release:minor": "npm version minor && npm run build && npm publish",
|
|
16
|
+
"release:major": "npm version major && npm run build && npm publish",
|
|
17
|
+
"version": "npm run build && git add dist/"
|
|
13
18
|
},
|
|
14
19
|
"keywords": [
|
|
15
20
|
"hirecontrol",
|
|
@@ -48,7 +48,7 @@ function useSiteConfig(clientToken, siteConfiguration = null) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Component to handle all context providers
|
|
51
|
-
const ContextProviders = ({ children, siteConfig, trackEvent, ...mapListProps }) => { return(
|
|
51
|
+
const ContextProviders = ({ children, siteConfig, trackEvent, googleMapsApiKey, ...mapListProps }) => { return(
|
|
52
52
|
<TrackEventProvider trackEvent={trackEvent}>
|
|
53
53
|
<ThemeProvider
|
|
54
54
|
uiText={siteConfig.colors.uiText}
|
|
@@ -63,6 +63,7 @@ const ContextProviders = ({ children, siteConfig, trackEvent, ...mapListProps })
|
|
|
63
63
|
<PlacesProvider
|
|
64
64
|
placeMappings={siteConfig.pointsOfInterestConfig.placeMappings ?? {}}
|
|
65
65
|
additionalMapMarkers={mapListProps.additionalMapMarkers}
|
|
66
|
+
googleMapsApiKey={googleMapsApiKey}
|
|
66
67
|
markerColors={{
|
|
67
68
|
fillColor: siteConfig.colors.primary,
|
|
68
69
|
strokeColor: siteConfig.colors.primaryDark,
|
|
@@ -87,6 +88,7 @@ const ContextProviders = ({ children, siteConfig, trackEvent, ...mapListProps })
|
|
|
87
88
|
//
|
|
88
89
|
export const HireControlMap = ({
|
|
89
90
|
clientToken,
|
|
91
|
+
googleMapsApiKey, // Required: Google Maps API key from Next.js
|
|
90
92
|
containerStyle = { height: '100vh' },
|
|
91
93
|
navigateToDetails = null,
|
|
92
94
|
navigateToEasyApply = null,
|
|
@@ -118,12 +120,27 @@ export const HireControlMap = ({
|
|
|
118
120
|
const { siteConfig, error } = useSiteConfig(clientToken, siteConfiguration);
|
|
119
121
|
|
|
120
122
|
// Load Google Maps
|
|
121
|
-
const { isLoaded: isMapsLoaded } = useLoadScript({
|
|
122
|
-
googleMapsApiKey:
|
|
123
|
+
const { isLoaded: isMapsLoaded, loadError } = useLoadScript({
|
|
124
|
+
googleMapsApiKey: googleMapsApiKey,
|
|
123
125
|
version: 'quarterly',
|
|
124
126
|
libraries: LIBRARIES
|
|
125
127
|
});
|
|
126
128
|
|
|
129
|
+
// Show loading state or error if Google Maps hasn't loaded yet
|
|
130
|
+
if (!googleMapsApiKey) {
|
|
131
|
+
console.error('Google Maps API key is required');
|
|
132
|
+
return <div className="hc-p-4">Google Maps API key is required</div>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (loadError) {
|
|
136
|
+
console.error('Google Maps failed to load:', loadError);
|
|
137
|
+
return <div className="hc-p-4">Error loading Google Maps</div>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!isMapsLoaded) {
|
|
141
|
+
return <div className="hc-p-4">Loading Maps...</div>;
|
|
142
|
+
}
|
|
143
|
+
|
|
127
144
|
if (error || !siteConfig) {
|
|
128
145
|
return <div className="hc-p-4"></div>;
|
|
129
146
|
}
|
|
@@ -169,6 +186,7 @@ export const HireControlMap = ({
|
|
|
169
186
|
<ContextProviders
|
|
170
187
|
siteConfig={siteConfig}
|
|
171
188
|
trackEvent={trackEvent}
|
|
189
|
+
googleMapsApiKey={googleMapsApiKey || process.env.GOOGLE_MAPS_API_KEY}
|
|
172
190
|
{...mapListProps}
|
|
173
191
|
>
|
|
174
192
|
<Grid
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
1
|
+
import React, { createContext, useContext, useEffect, useState, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import { markerIconProps } from '~/util/mapIconUtil';
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ const PlacesContext = createContext();
|
|
|
10
10
|
|
|
11
11
|
export const usePlaces = () => useContext(PlacesContext);
|
|
12
12
|
|
|
13
|
-
export const PlacesProvider = ({ children, placeMappings, markerColors, additionalMapMarkers }) => {
|
|
13
|
+
export const PlacesProvider = ({ children, placeMappings, markerColors, additionalMapMarkers, googleMapsApiKey }) => {
|
|
14
14
|
const { selectedPlaces, zoom, center } = useMap();
|
|
15
15
|
const [poiMarkers, setPoiMarkers] = useState({ markers: [], icon: null });
|
|
16
16
|
const [currentCenter, setCurrentCenter] = useState(center);
|
|
@@ -18,7 +18,7 @@ export const PlacesProvider = ({ children, placeMappings, markerColors, addition
|
|
|
18
18
|
const [placesWindow, setPlacesWindow] = useState(false);
|
|
19
19
|
const [selectedPlaceMarker, setSelectedPlaceMarker] = useState(null);
|
|
20
20
|
|
|
21
|
-
const getRadiusForZoom = () => {
|
|
21
|
+
const getRadiusForZoom = useCallback(() => {
|
|
22
22
|
if (currentZoom >= 18) return 1000;
|
|
23
23
|
if (currentZoom <= 10) return 0;
|
|
24
24
|
|
|
@@ -31,7 +31,7 @@ export const PlacesProvider = ({ children, placeMappings, markerColors, addition
|
|
|
31
31
|
else if (radius > maxRadius) radius = maxRadius;
|
|
32
32
|
|
|
33
33
|
return radius;
|
|
34
|
-
};
|
|
34
|
+
}, [currentZoom]);
|
|
35
35
|
|
|
36
36
|
useEffect(() => {
|
|
37
37
|
if (!selectedPlaces || (!selectedPlaces.length > 0) || !center || currentZoom < 12) {
|
|
@@ -49,7 +49,7 @@ export const PlacesProvider = ({ children, placeMappings, markerColors, addition
|
|
|
49
49
|
const location = { latitude: currentCenter.lat, longitude: currentCenter.lng };
|
|
50
50
|
|
|
51
51
|
try {
|
|
52
|
-
const response = await searchNearbyPlaces(poiTypes, location, radius);
|
|
52
|
+
const response = await searchNearbyPlaces(poiTypes, location, radius, googleMapsApiKey || process.env.GOOGLE_MAPS_API_KEY);
|
|
53
53
|
const newMarkers = response.places.map(place => {
|
|
54
54
|
const getParentCategory = types => {
|
|
55
55
|
const selectedTypes = selectedPOICategories.reduce((acc, category) => {
|
|
@@ -82,7 +82,7 @@ export const PlacesProvider = ({ children, placeMappings, markerColors, addition
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
fetchPlaces();
|
|
85
|
-
}, [selectedPlaces, currentZoom, currentCenter]);
|
|
85
|
+
}, [selectedPlaces, currentZoom, currentCenter, placeMappings, markerColors.placeMarkers, googleMapsApiKey, getRadiusForZoom, center]);
|
|
86
86
|
|
|
87
87
|
return (
|
|
88
88
|
<PlacesContext.Provider value={{
|
|
@@ -6,12 +6,13 @@ export interface Location {
|
|
|
6
6
|
export const searchNearbyPlaces = async (
|
|
7
7
|
typesArray: string[],
|
|
8
8
|
location: Location,
|
|
9
|
-
radius: number
|
|
9
|
+
radius: number,
|
|
10
|
+
apiKey?: string
|
|
10
11
|
): Promise<any> => {
|
|
11
12
|
const url = 'https://places.googleapis.com/v1/places:searchNearby';
|
|
12
13
|
const headers = {
|
|
13
14
|
'Content-Type': 'application/json',
|
|
14
|
-
'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY as string,
|
|
15
|
+
'X-Goog-Api-Key': apiKey || (process.env.GOOGLE_MAPS_API_KEY as string),
|
|
15
16
|
'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
|
|
16
17
|
};
|
|
17
18
|
const data = {
|