@abcagency/hc-ui-components 1.4.8 → 1.4.11
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/components/containers/accordions/filter-item-container.js +2 -2
- package/dist/components/containers/accordions/filter-item-container.js.map +1 -1
- package/dist/components/containers/accordions/map-accordion-item-container.js +6 -2
- package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
- package/dist/components/containers/filter/filter-item-container.js +10 -10
- package/dist/components/containers/filter/filter-item-container.js.map +1 -1
- package/dist/components/containers/maps/info-window-content-container.js.map +1 -1
- package/dist/components/containers/maps/map-container.js +0 -1
- package/dist/components/containers/maps/map-container.js.map +1 -1
- package/dist/components/modules/buttons/button-group-apply.js +12 -12
- package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
- package/dist/components/modules/dialogs/apply-dialog.js +4 -4
- package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
- package/dist/components/modules/list/field-mapper-desktop.js +2 -2
- package/dist/components/modules/list/field-mapper-desktop.js.map +1 -1
- package/dist/components/modules/list/field-mapper-mobile.js +8 -8
- package/dist/components/modules/list/field-mapper-mobile.js.map +1 -1
- package/dist/components/modules/list/header-item.js +1 -1
- package/dist/components/modules/list/header-item.js.map +1 -1
- package/dist/contexts/mapListContext.js +17 -15
- package/dist/contexts/mapListContext.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/services/listingAggregatorService.js +7 -8
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js +3 -2
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js +1 -16
- package/dist/services/listingService.js.map +1 -1
- package/dist/types/contexts/mapListContext.d.ts +1 -1
- package/dist/types/services/googlePlacesNearbyService.d.ts +1 -1
- package/dist/types/services/listingAggregatorService.d.ts +2 -2
- package/dist/types/services/listingEntityService.d.ts +2 -3
- package/dist/types/types/GetListingParams.d.ts +1 -1
- package/dist/types/types/ListingEntity.d.ts +2 -1
- package/dist/types/types/ListingFields.d.ts +4 -2
- package/dist/types/types/Listings.d.ts +0 -1
- package/dist/types/util/mapUtil.d.ts +3 -3
- package/dist/util/filterUtil.js +5 -5
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/mapUtil.js +33 -25
- package/dist/util/mapUtil.js.map +1 -1
- package/package.json +7 -2
- package/src/components/HireControlMap.js +21 -3
- package/src/components/containers/accordions/filter-item-container.js +2 -2
- package/src/components/containers/accordions/map-accordion-item-container.js +6 -2
- package/src/components/containers/filter/filter-item-container.js +10 -10
- package/src/components/containers/maps/info-window-content-container.js +1 -1
- package/src/components/containers/maps/map-container.js +2 -1
- package/src/components/modules/buttons/button-group-apply.js +8 -8
- package/src/components/modules/dialogs/apply-dialog.js +2 -2
- package/src/components/modules/list/field-mapper-desktop.jsx +2 -2
- package/src/components/modules/list/field-mapper-mobile.jsx +8 -8
- package/src/components/modules/list/header-item.js +1 -1
- package/src/contexts/mapListContext.tsx +37 -40
- package/src/contexts/placesContext.js +6 -6
- package/src/services/googlePlacesNearbyService.ts +3 -2
- package/src/services/listingAggregatorService.ts +12 -11
- package/src/services/listingEntityService.ts +3 -3
- package/src/services/listingService.ts +1 -11
- package/src/types/GetListingParams.ts +1 -1
- package/src/types/ListingEntity.ts +2 -1
- package/src/types/ListingFields.ts +4 -2
- package/src/types/Listings.ts +0 -1
- package/src/util/filterUtil.js +6 -6
- package/src/util/mapUtil.js +48 -41
package/dist/util/mapUtil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapUtil.js","sources":["../../src/util/mapUtil.js"],"sourcesContent":["export const getDistinctItemsByProximity = (items,
|
|
1
|
+
{"version":3,"file":"mapUtil.js","sources":["../../src/util/mapUtil.js"],"sourcesContent":["export const getDistinctItemsByProximity = (items, listingEntitiesDetailsInput) => {\n\tconst clusters = {};\n\n\tif (!listingEntitiesDetailsInput) return [];\n\n\tconst listingEntitiesDetails = Array.isArray(listingEntitiesDetailsInput)\n\t\t? listingEntitiesDetailsInput.reduce((acc, entity) => {\n\t\t\tif (entity?.entityKey) acc[entity.entityKey] = entity;\n\t\t\treturn acc;\n\t\t }, {})\n\t\t: listingEntitiesDetailsInput;\n\n\tconst closeItemPairs = findCloseItems(listingEntitiesDetails);\n\tif (closeItemPairs.length > 0) {\n\t\tconst adjusted = adjustItemPositions(listingEntitiesDetails, closeItemPairs);\n\t\tObject.assign(listingEntitiesDetails, adjusted);\n\t}\n\n\titems?.forEach(item => {\n\t\tconst entityKey = item?.fields?.entityKey;\n\t\tif (!entityKey || entityKey === '-1') return;\n\t\tconst entityDetails = listingEntitiesDetails[entityKey];\n\t\tif (!entityDetails) {\n\t\t\tconsole.error(`Details not found for entityKey: ${entityKey}`);\n\t\t\treturn;\n\t\t}\n\n\t\titem.mapDetails = entityDetails;\n\n\t\tif (!clusters[entityKey]) {\n\t\t\tclusters[entityKey] = {\n\t\t\t\t...entityDetails,\n\t\t\t\titems: { [item.id]: item }\n\t\t\t};\n\t\t} else {\n\t\t\tclusters[entityKey].items[item.id] = item;\n\t\t}\n\t});\n\n\treturn Object.values(clusters);\n};\n\nexport const findCloseItems = entitiesByKey => {\n\tconst closeItems = [];\n\tconst items = Object.values(entitiesByKey); // Convert object to array\n\tconst proximityThreshold = 0.0001;\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\tfor (let j = i + 1; j < items.length; j++) {\n\t\t\tconst distanceLat = Math.abs(items[i].latitude - items[j].latitude);\n\t\t\tconst distanceLng = Math.abs(items[i].longitude - items[j].longitude);\n\t\t\tif (distanceLat < proximityThreshold && distanceLng < proximityThreshold) {\n\t\t\t\tcloseItems.push({ item1: items[i], item2: items[j] });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn closeItems;\n};\n\nexport const adjustItemPositions = (entitiesByKey, closeItemPairs) => {\n\tconst adjustmentValue = 0.0001;\n\tconst adjustedItems = { ...entitiesByKey };\n\n\tcloseItemPairs.forEach(pair => {\n\t\tconst key2 = pair.item2.entityKey;\n\t\tif (adjustedItems[key2]) {\n\t\t\tadjustedItems[key2] = {\n\t\t\t\t...adjustedItems[key2],\n\t\t\t\tlatitude: adjustedItems[key2].latitude + adjustmentValue,\n\t\t\t\tlongitude: adjustedItems[key2].longitude + adjustmentValue\n\t\t\t};\n\t\t}\n\t});\n\n\treturn adjustedItems;\n};\n\nexport const clusterOptions = (clusterGridSize, fillColor) => {\n\treturn {\n\t\tgridSize: clusterGridSize,\n\t\tmaxZoom: 15,\n\t\tstyles: [\n\t\t\t{\n\t\t\t\turl: createSvgDataUri(fillColor),\n\t\t\t\ttextColor: 'white',\n\t\t\t\theight: 40,\n\t\t\t\twidth: 40\n\t\t\t}\n\t\t]\n\t};\n};\n\nfunction createSvgDataUri(fillColor) {\n\tconst svg = `<svg width=\"50\" height=\"50\" xmlns=\"http://www.w3.org/2000/svg\">\n\t <circle cx=\"25\" cy=\"25\" r=\"20\" fill=\"${fillColor}\" />\n\t</svg>`;\n\treturn `data:image/svg+xml;base64,${btoa(svg)}`;\n}\n"],"names":["getDistinctItemsByProximity","items","listingEntitiesDetailsInput","clusters","listingEntitiesDetails","Array","isArray","reduce","acc","entity","entityKey","closeItemPairs","findCloseItems","length","adjusted","adjustItemPositions","Object","assign","forEach","item","_item$fields","fields","entityDetails","console","error","concat","mapDetails","_objectSpread","_defineProperty","id","values","entitiesByKey","closeItems","proximityThreshold","i","j","distanceLat","Math","abs","latitude","distanceLng","longitude","push","item1","item2","adjustmentValue","adjustedItems","pair","key2","clusterOptions","clusterGridSize","fillColor","gridSize","maxZoom","styles","url","createSvgDataUri","textColor","height","width","svg","btoa"],"mappings":";;AAAO,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAAIC,KAAK,EAA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AAA;AACD,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOC,aAAa,CAAA;AACrB,EAAC;AAEM,IAAMG,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,eAAe,EAAEC,SAAS,EAAK;EAC7D,OAAO;AACNC,IAAAA,QAAQ,EAAEF,eAAe;AACzBG,IAAAA,OAAO,EAAE,EAAE;AACXC,IAAAA,MAAM,EAAE,CACP;AACCC,MAAAA,GAAG,EAAEC,gBAAgB,CAACL,SAAS,CAAC;AAChCM,MAAAA,SAAS,EAAE,OAAO;AAClBC,MAAAA,MAAM,EAAE,EAAE;AACVC,MAAAA,KAAK,EAAE,EAAA;KACP,CAAA;GAEF,CAAA;AACF,EAAC;AAED,SAASH,gBAAgBA,CAACL,SAAS,EAAE;AACpC,EAAA,IAAMS,GAAG,GAAA,yHAAA,CAAAnC,MAAA,CACgC0B,SAAS,EAC3C,iBAAA,CAAA,CAAA;AACP,EAAA,OAAA,4BAAA,CAAA1B,MAAA,CAAoCoC,IAAI,CAACD,GAAG,CAAC,CAAA,CAAA;AAC9C;;;;"}
|
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.11",
|
|
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
|
|
@@ -21,8 +21,8 @@ const FilterItemContainer = ({
|
|
|
21
21
|
event.stopPropagation();
|
|
22
22
|
setSelectedFilters(prevFilters => {
|
|
23
23
|
const updatedFilters = { ...prevFilters };
|
|
24
|
-
if(subcategoryRequireCategory && fieldKey == '
|
|
25
|
-
delete updatedFilters['
|
|
24
|
+
if(subcategoryRequireCategory && fieldKey == 'category'){
|
|
25
|
+
delete updatedFilters['subCategory'];
|
|
26
26
|
}
|
|
27
27
|
if(fieldKey == 'state' || fieldKey == 'city' || fieldKey == 'cityState'){
|
|
28
28
|
delete updatedFilters.entityId;
|
|
@@ -25,7 +25,11 @@ const MapAccordionItemContainer = ({
|
|
|
25
25
|
selectItem(null, null, 9, { lat: 39.8283, lng: -98.5795 });
|
|
26
26
|
} else {
|
|
27
27
|
setStorageObject("selectedListItem", item);
|
|
28
|
-
|
|
28
|
+
console.log('mapItems here', mapItems);
|
|
29
|
+
//edited here for new structure of entity key
|
|
30
|
+
console.log('the item in questions is',item);
|
|
31
|
+
const location = mapItems.find(x => Object.prototype.hasOwnProperty.call(x.items, item.fields.entityKey)) || null;
|
|
32
|
+
console.log('location is', location);
|
|
29
33
|
selectItem(item, location, 12, {
|
|
30
34
|
lat: location?.latitude,
|
|
31
35
|
lng: location?.longitude
|
|
@@ -35,7 +39,7 @@ const MapAccordionItemContainer = ({
|
|
|
35
39
|
|
|
36
40
|
const handleItemClick = item => {
|
|
37
41
|
trackEvent(eventTypes.JOB_LISTING_SELECTED, {
|
|
38
|
-
jobTitle: item.fields.
|
|
42
|
+
jobTitle: item.fields.title,
|
|
39
43
|
jobCategory: item.fields.category,
|
|
40
44
|
entityDisplayName: item?.mapDetails?.entityDisplayName
|
|
41
45
|
});
|
|
@@ -55,30 +55,30 @@ const FilterItemContainer = ({
|
|
|
55
55
|
delete updatedFilters[field];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
if (field === '
|
|
58
|
+
if (field === 'category' && subcategoryRequireCategory) {
|
|
59
59
|
const activeCategoryClass = itemKey;
|
|
60
60
|
const categoriesToConsiderForRemoval = new Set(
|
|
61
61
|
filteredListings
|
|
62
|
-
.filter(listing => listing.fields.
|
|
63
|
-
.flatMap(listing => listing.fields.
|
|
62
|
+
.filter(listing => listing.fields.category === activeCategoryClass)
|
|
63
|
+
.flatMap(listing => listing.fields.subCategory || [])
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
const categoriesToRetain = new Set(
|
|
67
67
|
filteredListings
|
|
68
|
-
.filter(listing => listing.fields.
|
|
69
|
-
.flatMap(listing => listing.fields.
|
|
68
|
+
.filter(listing => listing.fields.category !== activeCategoryClass)
|
|
69
|
+
.flatMap(listing => listing.fields.subCategory || [])
|
|
70
70
|
.filter(category => categoriesToConsiderForRemoval.has(category))
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
-
if (updatedFilters['
|
|
74
|
-
Object.keys(updatedFilters['
|
|
73
|
+
if (updatedFilters['subCategory']) {
|
|
74
|
+
Object.keys(updatedFilters['subCategory']).forEach(categoryKey => {
|
|
75
75
|
if (categoriesToConsiderForRemoval.has(categoryKey) && !categoriesToRetain.has(categoryKey)) {
|
|
76
|
-
delete updatedFilters['
|
|
76
|
+
delete updatedFilters['subCategory'][categoryKey];
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
if (Object.keys(updatedFilters['
|
|
81
|
-
delete updatedFilters['
|
|
80
|
+
if (Object.keys(updatedFilters['subCategory']).length === 0) {
|
|
81
|
+
delete updatedFilters['subCategory'];
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -57,7 +57,7 @@ const InfoWindowContentContainer = ({
|
|
|
57
57
|
newFilters.state = { [items[0].fields.state]: true };
|
|
58
58
|
filters.push({ filterType: 'state', filterChecked: items[0].fields.state });
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
newFilters.entityName = { [items[0].fields.entityName]: true };
|
|
62
62
|
filters.push({ filterType: 'entityName', filterChecked: items[0].fields.entityName });
|
|
63
63
|
|
|
@@ -256,9 +256,10 @@ const MapContainer = ({ markerConfigs, infoWindowClasses, clusterGridSize = 60 }
|
|
|
256
256
|
if (!mapItems) {
|
|
257
257
|
return null;
|
|
258
258
|
}
|
|
259
|
+
|
|
259
260
|
const mapItemsKey = mapItems.map(item => item.id).join("-");
|
|
260
261
|
|
|
261
|
-
|
|
262
|
+
|
|
262
263
|
return (
|
|
263
264
|
<Map
|
|
264
265
|
zoom={zoom}
|
|
@@ -31,19 +31,19 @@ const ButtonGroupApply = ({
|
|
|
31
31
|
|
|
32
32
|
const trackApplyNow = () => {
|
|
33
33
|
//console.log('calling trackApplyNow');
|
|
34
|
-
trackEvent(eventTypes.APPLY_NOW_CLICKED, { jobCategory: item.fields.
|
|
34
|
+
trackEvent(eventTypes.APPLY_NOW_CLICKED, { jobCategory: item.fields.subCategory, jobCategoryClass: item.fields.category, jobEntity: item.fields.entityName, jobListingId: item.id, jobSchedule: item.fields.schedule });
|
|
35
35
|
};
|
|
36
36
|
const trackApplyOpen = () => {
|
|
37
37
|
//console.log('calling trackApplyOpen');
|
|
38
|
-
trackEvent(eventTypes.APPLY_OPEN_CLICKED, { jobCategory: item.fields.
|
|
38
|
+
trackEvent(eventTypes.APPLY_OPEN_CLICKED, { jobCategory: item.fields.subCategory, jobCategoryClass: item.fields.category, jobEntity: item.fields.entityName, jobListingId: item.id, jobSchedule: item.fields.schedule });
|
|
39
39
|
};
|
|
40
40
|
const trackEasyApply = () => {
|
|
41
41
|
//console.log('calling trackEasyApply');
|
|
42
|
-
trackEvent(eventTypes.EASY_APPLY_CLICKED, { jobCategory: item.fields.
|
|
42
|
+
trackEvent(eventTypes.EASY_APPLY_CLICKED, { jobCategory: item.fields.subCategory, jobCategoryClass: item.fields.category, jobEntity: item.fields.entityName, jobListingId: item.id, jobSchedule: item.fields.schedule });
|
|
43
43
|
};
|
|
44
44
|
const trackViewDetails = () => {
|
|
45
45
|
//console.log('calling trackViewDetails');
|
|
46
|
-
trackEvent(eventTypes.VIEW_DETAILS_CLICKED, { jobCategory: item.fields.
|
|
46
|
+
trackEvent(eventTypes.VIEW_DETAILS_CLICKED, { jobCategory: item.fields.subCategory, jobCategoryClass: item.fields.category, jobEntity: item.fields.entityName, jobListingId: item.id, jobSchedule: item.fields.schedule });
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
return (
|
|
@@ -78,9 +78,9 @@ const ButtonGroupApply = ({
|
|
|
78
78
|
</Button.Anchor>
|
|
79
79
|
) : null}
|
|
80
80
|
|
|
81
|
-
{item.applyOnline ==
|
|
81
|
+
{item.fields.applyOnline == true && item.fields.applyUrl && !includeDialog &&
|
|
82
82
|
<Button.Anchor
|
|
83
|
-
href={item.applyUrl}
|
|
83
|
+
href={item.fields.applyUrl}
|
|
84
84
|
variant={applyButtonVariant}
|
|
85
85
|
size={buttonSize}
|
|
86
86
|
className={"map-apply-now-button"}
|
|
@@ -91,8 +91,8 @@ const ButtonGroupApply = ({
|
|
|
91
91
|
{applyNowText}
|
|
92
92
|
</Button.Anchor>
|
|
93
93
|
}
|
|
94
|
-
{item.applyOnline ==
|
|
95
|
-
<ApplyDialog applyUrl={item.applyUrl} internalApplyLink={internalApplyLink} companyName={companyName} item={item} trackEvent={trackEvent} eventTypes={eventTypes} isIframe={isIframe}>
|
|
94
|
+
{item.fields.applyOnline == true && item.fields.applyUrl && includeDialog &&
|
|
95
|
+
<ApplyDialog applyUrl={item.fields.applyUrl} internalApplyLink={internalApplyLink} companyName={companyName} item={item} trackEvent={trackEvent} eventTypes={eventTypes} isIframe={isIframe}>
|
|
96
96
|
<Button.Anchor
|
|
97
97
|
variant={applyButtonVariant}
|
|
98
98
|
size={buttonSize}
|
|
@@ -7,11 +7,11 @@ import Icon from '~/components/modules/icon';
|
|
|
7
7
|
const ApplyDialog = ({ children, applyUrl, internalApplyLink, companyName, item, trackEvent, eventTypes, isIframe }) => {
|
|
8
8
|
const trackApplyOption1 = () => {
|
|
9
9
|
//console.log('calling trackApplyOption1');
|
|
10
|
-
trackEvent(eventTypes.APPLY_OPTION_1_CLICKED, { jobCategory: item.fields.
|
|
10
|
+
trackEvent(eventTypes.APPLY_OPTION_1_CLICKED, { jobCategory: item.fields.subCategory, jobCategoryClass: item.fields.category, jobEntity: item.fields.entityName, jobListingId: item.id, jobSchedule: item.fields.schedule });
|
|
11
11
|
};
|
|
12
12
|
const trackApplyOption2 = () => {
|
|
13
13
|
//console.log('calling trackApplyOption2');
|
|
14
|
-
trackEvent(eventTypes.APPLY_OPTION_2_CLICKED, { jobCategory: item.fields.
|
|
14
|
+
trackEvent(eventTypes.APPLY_OPTION_2_CLICKED, { jobCategory: item.fields.subCategory, jobCategoryClass: item.fields.category, jobEntity: item.fields.entityName, jobListingId: item.id, jobSchedule: item.fields.schedule });
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
return (
|
|
@@ -11,7 +11,7 @@ const FieldMapperDesktop = ({
|
|
|
11
11
|
const orderedFields = fieldsShown.filter(field => field in item.fields);
|
|
12
12
|
|
|
13
13
|
const specialFeaturePills = field => {
|
|
14
|
-
return field === '
|
|
14
|
+
return field === 'title' && specialFeatures &&
|
|
15
15
|
Object.entries(specialFeatures).map(([featureKey, featureLabel]) => {
|
|
16
16
|
return item.fields[featureKey] == 1 && (
|
|
17
17
|
<PillWrapper key={featureKey}>{featureLabel}</PillWrapper>
|
|
@@ -29,7 +29,7 @@ const FieldMapperDesktop = ({
|
|
|
29
29
|
className={`
|
|
30
30
|
hc-hidden md:hc-block hc-px-2
|
|
31
31
|
${index === 0 ? "hc-pl-7" : ""}
|
|
32
|
-
${field.toLowerCase() === "
|
|
32
|
+
${field.toLowerCase() === "title" ? "hc-col-span-4 hc-text-balance hc-font-semibold" : (field.toLowerCase() === "state" || field.toLowerCase() == "favorite") ? "hc-col-span-1" : "hc-col-span-2"}
|
|
33
33
|
`}
|
|
34
34
|
>
|
|
35
35
|
<span className="hc-sr-only">{capitalize(field)}</span>
|
|
@@ -12,7 +12,7 @@ const FieldMapperMobile = ({
|
|
|
12
12
|
includeFavorite = true
|
|
13
13
|
}) => {
|
|
14
14
|
const specialFeaturePills = field => {
|
|
15
|
-
return field === '
|
|
15
|
+
return field === 'title' && specialFeatures &&
|
|
16
16
|
Object.entries(specialFeatures).map(([featureKey, featureLabel]) => {
|
|
17
17
|
return item.fields[featureKey] == 1 && (
|
|
18
18
|
<PillWrapper key={featureKey}>{featureLabel}</PillWrapper>
|
|
@@ -22,11 +22,11 @@ const FieldMapperMobile = ({
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<Grid.Item className="md:hc-hidden">
|
|
25
|
-
{fieldsShown.includes("
|
|
25
|
+
{fieldsShown.includes("title") &&
|
|
26
26
|
<>
|
|
27
27
|
<div className="hc-flex hc-items-start">
|
|
28
28
|
<div className="hc-flex hc-justify-between hc-items-center hc-min-w-[100%]">
|
|
29
|
-
<h3 className="hc-font-bold hc-mb-3 hc-flex-1">{item.fields.
|
|
29
|
+
<h3 className="hc-font-bold hc-mb-3 hc-flex-1">{item.fields.title}</h3>
|
|
30
30
|
{includeFavorite && <div className="hc-flex hc-justify-end hc-pb-2">
|
|
31
31
|
<Icon
|
|
32
32
|
icon={isFavorite ? "mdi:heart" : "mdi:heart-outline"}
|
|
@@ -41,20 +41,20 @@ const FieldMapperMobile = ({
|
|
|
41
41
|
}
|
|
42
42
|
</div>
|
|
43
43
|
</div>
|
|
44
|
-
{specialFeatures && <div className='hc-pb-4'>{specialFeaturePills("
|
|
44
|
+
{specialFeatures && <div className='hc-pb-4'>{specialFeaturePills("title", true)} </div>}
|
|
45
45
|
</>
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
<ul className="hc-space-y-2 hc-text-xs">
|
|
49
49
|
{[
|
|
50
50
|
{
|
|
51
|
-
field: "
|
|
52
|
-
name: "
|
|
51
|
+
field: "category",
|
|
52
|
+
name: "category",
|
|
53
53
|
icon: "icon-park-solid:tree-list"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
field: "
|
|
57
|
-
name: "
|
|
56
|
+
field: "subCategory",
|
|
57
|
+
name: "subCategory",
|
|
58
58
|
icon: "icon-park-solid:tree-list"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
@@ -57,7 +57,7 @@ const HeaderItem = ({
|
|
|
57
57
|
size="none"
|
|
58
58
|
className={`
|
|
59
59
|
hc-p-2 hc-rounded-none hc-text-left hc-normal-case hover:hc-bg-uiAccent/5 focus:hc-bg-uiAccent/5
|
|
60
|
-
${field.toLowerCase() === "
|
|
60
|
+
${field.toLowerCase() === "title" ? "hc-pl-7 hc-col-span-4" : (field.toLowerCase() === "state" || field.toLowerCase() == "favorite") ? "hc-col-span-1" : "hc-col-span-2"}
|
|
61
61
|
${className ?? ""}
|
|
62
62
|
`}
|
|
63
63
|
{...rest}
|
|
@@ -93,7 +93,7 @@ interface MapListProviderProps {
|
|
|
93
93
|
defaultFilters?: Record<string, any>;
|
|
94
94
|
containerStyle?: any;
|
|
95
95
|
localStorageKey: string;
|
|
96
|
-
getListingEntitiesCallback?: (
|
|
96
|
+
getListingEntitiesCallback?: (origin?: string) => Promise<any>;
|
|
97
97
|
ExpandListComponent?: React.ComponentType<{ listing: Listing }> | ((listing: Listing) => JSX.Element) | null;
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -160,34 +160,31 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
|
|
|
160
160
|
setStorageObject("commuteLocation", commuteLocation);
|
|
161
161
|
}, [commuteLocation]);
|
|
162
162
|
|
|
163
|
+
|
|
163
164
|
useEffect(() => {
|
|
164
165
|
if (!commuteLocation) return;
|
|
165
166
|
|
|
166
167
|
async function fetchEntities() {
|
|
167
|
-
const distinctEntityIds = [
|
|
168
|
-
...new Set(allListings.map(listing => listing.entityId ?? -1))
|
|
169
|
-
];
|
|
170
168
|
try {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
);
|
|
169
|
+
let fetchedEntities;
|
|
170
|
+
if (getListingEntitiesCallback) {
|
|
171
|
+
fetchedEntities = await getListingEntitiesCallback(`${commuteLocation.lat}, ${commuteLocation.lng}`);
|
|
172
|
+
} else {
|
|
173
|
+
fetchedEntities = await getListingEntities(`${commuteLocation.lat}, ${commuteLocation.lng}`);
|
|
174
|
+
}
|
|
178
175
|
setListingEntities(fetchedEntities);
|
|
179
|
-
|
|
176
|
+
// Update travelTime on listings
|
|
177
|
+
const newFilteredListings: Listing[] = [...filteredListings];
|
|
180
178
|
for (let i = 0; i < allListings.length; i++) {
|
|
181
179
|
const listing = newFilteredListings[i];
|
|
182
180
|
if (
|
|
183
181
|
listing &&
|
|
184
182
|
listing.fields &&
|
|
185
|
-
listing.
|
|
186
|
-
listing.
|
|
183
|
+
listing.fields.entityKey &&
|
|
184
|
+
listing.fields.entityKey !== ''
|
|
187
185
|
) {
|
|
188
|
-
const
|
|
189
|
-
const travelTime = fetchedEntities[
|
|
190
|
-
|
|
186
|
+
const entityKey = listing.fields.entityKey;
|
|
187
|
+
const travelTime = fetchedEntities[entityKey]?.travelTime;
|
|
191
188
|
if (travelTime !== undefined && listing.fields) {
|
|
192
189
|
listing.fields.travelTime = travelTime;
|
|
193
190
|
}
|
|
@@ -199,35 +196,35 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
|
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
fetchEntities();
|
|
202
|
-
}, [commuteLocation, allListings, siteConfig.companyId]);
|
|
199
|
+
}, [commuteLocation, allListings, siteConfig.companyId, getListingEntitiesCallback]);
|
|
203
200
|
|
|
204
201
|
useEffect(() => {
|
|
205
202
|
const handleFetchListings = async () => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
203
|
+
if (!(getStorageObject('listings', []) || []).length) {
|
|
204
|
+
setLoading(true);
|
|
205
|
+
}
|
|
209
206
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
207
|
+
try {
|
|
208
|
+
const {
|
|
209
|
+
listingsResult,
|
|
210
|
+
entitiesByKey,
|
|
211
|
+
distinctItems
|
|
212
|
+
} = await fetchListings(commuteLocation, entities, listings, getListingEntitiesCallback);
|
|
213
|
+
if (defaultFilters) {
|
|
214
|
+
const filteredListings = listingsResult.filter(listing => {
|
|
215
|
+
if (!listing.fields) return false;
|
|
219
216
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
});
|
|
217
|
+
return Object.keys(defaultFilters).every(filterKey => {
|
|
218
|
+
const filterValues = defaultFilters[filterKey as keyof typeof defaultFilters];
|
|
219
|
+
const listingValue = listing.fields ? listing.fields[filterKey as keyof typeof listing.fields] : null;
|
|
220
|
+
return filterValues.includes(listingValue);
|
|
225
221
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
222
|
+
});
|
|
223
|
+
setAllListings(filteredListings);
|
|
224
|
+
} else {
|
|
225
|
+
setAllListings(listingsResult);
|
|
226
|
+
}
|
|
227
|
+
setListingEntities(entitiesByKey);
|
|
231
228
|
setMapItems(distinctItems);
|
|
232
229
|
} catch (error) {
|
|
233
230
|
console.log(error);
|
|
@@ -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 = {
|
|
@@ -6,7 +6,8 @@ import { ListingEntity } from '~/types/ListingEntity';
|
|
|
6
6
|
|
|
7
7
|
interface FetchListingsResult {
|
|
8
8
|
listingsResult: Listing[];
|
|
9
|
-
|
|
9
|
+
entitiesByKey: Record<string, ListingEntity>;
|
|
10
|
+
|
|
10
11
|
distinctItems: any; // Update this type based on the return type of getDistinctItemsByProximity
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -14,25 +15,25 @@ const fetchListings = async (
|
|
|
14
15
|
commuteLocation: any | null = null,
|
|
15
16
|
entities: ListingEntity[] | null,
|
|
16
17
|
listings: Listing[] | null,
|
|
17
|
-
getListingEntitiesCallback?: (
|
|
18
|
+
getListingEntitiesCallback?: (origin?: string) => Promise<ListingEntity[]>,
|
|
18
19
|
): Promise<FetchListingsResult> => {
|
|
19
20
|
try {
|
|
20
21
|
const listingsResult = listings && listings.length > 0 ? listings : await getListings();
|
|
21
|
-
const distinctEntityIds: number[] = [
|
|
22
|
-
...new Set(listingsResult.map(listing => listing.entityId))
|
|
23
|
-
] as number[];
|
|
24
22
|
|
|
25
23
|
const fetchedEntities = !commuteLocation
|
|
26
|
-
? entities && entities.length > 0 ? entities : !getListingEntitiesCallback ? await getListingEntities(
|
|
24
|
+
? entities && entities.length > 0 ? entities : !getListingEntitiesCallback ? await getListingEntities() : await getListingEntitiesCallback()
|
|
27
25
|
: !getListingEntitiesCallback ? await getListingEntities(
|
|
28
|
-
|
|
26
|
+
|
|
29
27
|
`${commuteLocation.lat}, ${commuteLocation.lng}`
|
|
30
|
-
) : await getListingEntitiesCallback(
|
|
28
|
+
) : await getListingEntitiesCallback(
|
|
31
29
|
`${commuteLocation.lat}, ${commuteLocation.lng}`);
|
|
30
|
+
const entitiesByKey = fetchedEntities;
|
|
32
31
|
for (let i = 0; i < listingsResult.length; i++) {
|
|
33
32
|
const listing = listingsResult[i];
|
|
34
|
-
|
|
35
|
-
const entity =
|
|
33
|
+
if (listing.fields && listing.fields.entityKey && listing.fields.entityKey !== '' && listing.fields) {
|
|
34
|
+
const entity = entitiesByKey[listing.fields.entityKey];
|
|
35
|
+
console.log("Entity for listing with travel time", listing.fields.entityKey, entity);
|
|
36
|
+
|
|
36
37
|
if (entity) {
|
|
37
38
|
listing.fields.travelTime = entity.travelTime;
|
|
38
39
|
}
|
|
@@ -46,7 +47,7 @@ const fetchListings = async (
|
|
|
46
47
|
|
|
47
48
|
return {
|
|
48
49
|
listingsResult,
|
|
49
|
-
|
|
50
|
+
entitiesByKey,
|
|
50
51
|
distinctItems
|
|
51
52
|
};
|
|
52
53
|
} catch (error) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import api from '~/apis/hcApi';
|
|
2
|
-
import { ListingEntity } from '~/types/ListingEntity';
|
|
3
2
|
|
|
4
|
-
export const getListingEntities = async (
|
|
3
|
+
export const getListingEntities = async (origin = ''): Promise<any> => {
|
|
5
4
|
try {
|
|
6
|
-
|
|
5
|
+
//need to update / or add better endpoint fo this to match original functioanlity
|
|
6
|
+
const response = await api.get<any>(`/listingentities/MapEntities?origin=${origin}`);
|
|
7
7
|
return response;
|
|
8
8
|
} catch (error) {
|
|
9
9
|
console.error("Error fetching listing entities:", error);
|