@abcagency/hc-ui-components 1.3.14 → 1.3.16
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/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/apis/hcApi.js +1 -1
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/clientToken.js.map +1 -1
- package/dist/components/HireControlMap.js +15 -5
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/modules/accordions/MapAccordionItem.js +11 -1
- package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
- package/dist/components/modules/accordions/default.js.map +1 -1
- package/dist/components/modules/accordions/filterItem.js +2 -1
- package/dist/components/modules/accordions/filterItem.js.map +1 -1
- package/dist/components/modules/accordions/filters.js +0 -3
- package/dist/components/modules/accordions/filters.js.map +1 -1
- package/dist/components/modules/buttons/button-group-apply.js +36 -15
- package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
- package/dist/components/modules/buttons/commute-pill.js.map +1 -1
- package/dist/components/modules/buttons/default.js.map +1 -1
- package/dist/components/modules/buttons/items-pill.js.map +1 -1
- package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
- package/dist/components/modules/buttons/show-all-button.js.map +1 -1
- package/dist/components/modules/cards/default.js.map +1 -1
- package/dist/components/modules/cards/filter.js.map +1 -1
- package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
- package/dist/components/modules/filter/commute.js +22 -6
- package/dist/components/modules/filter/commute.js.map +1 -1
- package/dist/components/modules/filter/index.js +7 -0
- package/dist/components/modules/filter/index.js.map +1 -1
- package/dist/components/modules/filter/item.js +16 -1
- package/dist/components/modules/filter/item.js.map +1 -1
- package/dist/components/modules/filter/location.js +1 -1
- package/dist/components/modules/filter/location.js.map +1 -1
- package/dist/components/modules/filter/points-of-interest.js.map +1 -1
- package/dist/components/modules/filter/radio-item.js +7 -0
- package/dist/components/modules/filter/radio-item.js.map +1 -1
- package/dist/components/modules/filter/search.js.map +1 -1
- package/dist/components/modules/filter/sort.js.map +1 -1
- package/dist/components/modules/grid.js.map +1 -1
- package/dist/components/modules/icon.js.map +1 -1
- package/dist/components/modules/jobListing/listing-details.js +6 -0
- package/dist/components/modules/jobListing/listing-details.js.map +1 -1
- package/dist/components/modules/maps/info-window-card.js.map +1 -1
- package/dist/components/modules/maps/info-window-content.js +20 -0
- package/dist/components/modules/maps/info-window-content.js.map +1 -1
- package/dist/components/modules/maps/list/field-mapper.js.map +1 -1
- package/dist/components/modules/maps/list/header-item.js.map +1 -1
- package/dist/components/modules/maps/list/header.js.map +1 -1
- package/dist/components/modules/maps/list/index.js +21 -12
- package/dist/components/modules/maps/list/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
- package/dist/components/modules/maps/list/list-item/index.js +12 -2
- package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
- package/dist/components/modules/maps/map-list.js.map +1 -1
- package/dist/components/modules/maps/map-marker.js +10 -0
- package/dist/components/modules/maps/map-marker.js.map +1 -1
- package/dist/components/modules/maps/map.js.map +1 -1
- package/dist/components/modules/maps/place-marker.js.map +1 -1
- package/dist/components/modules/maps/tabs.js.map +1 -1
- package/dist/constants/eventTypes.js +16 -0
- package/dist/constants/eventTypes.js.map +1 -0
- package/dist/constants/placeTypes.js.map +1 -1
- package/dist/contexts/mapContext.js +9 -27
- package/dist/contexts/mapContext.js.map +1 -1
- package/dist/contexts/mapListContext.js +57 -38
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/contexts/placesContext.js.map +1 -1
- package/dist/contexts/trackEventContext.js +20 -0
- package/dist/contexts/trackEventContext.js.map +1 -0
- package/dist/hooks/useList.js +1 -13
- package/dist/hooks/useList.js.map +1 -1
- package/dist/services/apis/hcApi.js +1 -1
- package/dist/services/apis/hcApi.js.map +1 -1
- package/dist/services/clientToken.js.map +1 -1
- package/dist/services/configService.js.map +1 -1
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/services/listingAggregatorService.js +43 -16
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js.map +1 -1
- package/dist/services/recruiterService.js.map +1 -1
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/loading.js.map +1 -1
- package/dist/util/localStorageUtil.js.map +1 -1
- package/dist/util/mapIconUtil.js.map +1 -1
- package/dist/util/mapUtil.js.map +1 -1
- package/dist/util/sortUtil.js.map +1 -1
- package/dist/util/stringUtils.js.map +1 -1
- package/jsconfig.json +7 -7
- package/package.json +60 -60
- package/postcss.config.js +13 -13
- package/preset.default.js +15 -15
- package/rollup.config.mjs +88 -87
- package/src/apis/hcApi.js +93 -93
- package/src/clientToken.js +9 -9
- package/src/components/HireControlMap.js +129 -124
- package/src/components/modules/accordions/MapAccordionItem.js +74 -72
- package/src/components/modules/accordions/default.js +171 -171
- package/src/components/modules/accordions/filterItem.js +55 -53
- package/src/components/modules/accordions/filters.js +47 -47
- package/src/components/modules/buttons/button-group-apply.js +123 -116
- package/src/components/modules/buttons/commute-pill.js +22 -22
- package/src/components/modules/buttons/default.js +194 -194
- package/src/components/modules/buttons/items-pill.js +35 -35
- package/src/components/modules/buttons/pill-wrapper.js +27 -27
- package/src/components/modules/buttons/show-all-button.js +20 -20
- package/src/components/modules/cards/default.js +167 -167
- package/src/components/modules/cards/filter.js +56 -56
- package/src/components/modules/dialogs/apply-dialog.js +48 -48
- package/src/components/modules/filter/commute.js +154 -149
- package/src/components/modules/filter/index.js +89 -87
- package/src/components/modules/filter/item.js +87 -76
- package/src/components/modules/filter/location.js +71 -71
- package/src/components/modules/filter/points-of-interest.js +44 -44
- package/src/components/modules/filter/radio-item.js +57 -53
- package/src/components/modules/filter/search.js +92 -92
- package/src/components/modules/filter/sort.js +83 -83
- package/src/components/modules/grid.js +54 -54
- package/src/components/modules/icon.js +33 -33
- package/src/components/modules/jobListing/listing-details.js +99 -95
- package/src/components/modules/maps/info-window-card.js +17 -17
- package/src/components/modules/maps/info-window-content.js +81 -74
- package/src/components/modules/maps/list/field-mapper.js +112 -112
- package/src/components/modules/maps/list/header-item.js +91 -91
- package/src/components/modules/maps/list/header.js +47 -47
- package/src/components/modules/maps/list/index.js +112 -107
- package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
- package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
- package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
- package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
- package/src/components/modules/maps/list/list-item/index.js +135 -133
- package/src/components/modules/maps/map-list.js +74 -74
- package/src/components/modules/maps/map-marker.js +88 -86
- package/src/components/modules/maps/map.js +230 -230
- package/src/components/modules/maps/place-marker.js +41 -41
- package/src/components/modules/maps/tabs.js +81 -81
- package/src/constants/eventTypes.js +13 -0
- package/src/constants/placeTypes.js +8 -8
- package/src/contexts/mapContext.js +101 -115
- package/src/contexts/mapListContext.js +242 -222
- package/src/contexts/placesContext.js +102 -102
- package/src/contexts/trackEventContext.js +14 -0
- package/src/hooks/useList.js +89 -100
- package/src/index.js +3 -3
- package/src/services/configService.js +16 -16
- package/src/services/googlePlacesNearbyService.js +33 -33
- package/src/services/listingAggregatorService.js +50 -45
- package/src/services/listingEntityService.js +15 -15
- package/src/services/listingService.js +26 -26
- package/src/services/recruiterService.js +17 -17
- package/src/styles/index.css +23 -23
- package/src/util/arrayUtil.js +3 -3
- package/src/util/fieldMapper.js +22 -22
- package/src/util/filterUtil.js +195 -195
- package/src/util/loading.js +17 -17
- package/src/util/localStorageUtil.js +26 -26
- package/src/util/mapIconUtil.js +180 -180
- package/src/util/mapUtil.js +91 -91
- package/src/util/sortUtil.js +32 -32
- package/src/util/stringUtils.js +6 -6
- package/src/util/urlFilterUtil.js +90 -90
- package/tailwind.config.js +126 -126
- package/.editorconfig +0 -12
- package/.eslintrc +0 -105
- package/.prettierignore +0 -3
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { markerIconProps } from '~/util/mapIconUtil';
|
|
4
|
-
|
|
5
|
-
import { useMap } from '~/contexts/mapContext';
|
|
6
|
-
|
|
7
|
-
import { searchNearbyPlaces } from '~/services/googlePlacesNearbyService';
|
|
8
|
-
|
|
9
|
-
const PlacesContext = createContext();
|
|
10
|
-
|
|
11
|
-
export const usePlaces = () => useContext(PlacesContext);
|
|
12
|
-
|
|
13
|
-
export const PlacesProvider = ({ children, placeMappings, markerColors }) => {
|
|
14
|
-
const { selectedPlaces, zoom, center } = useMap();
|
|
15
|
-
const [poiMarkers, setPoiMarkers] = useState({ markers: [], icon: null });
|
|
16
|
-
const [currentCenter, setCurrentCenter] = useState(center);
|
|
17
|
-
const [currentZoom, setCurrentZoom] = useState(zoom);
|
|
18
|
-
const [placesWindow, setPlacesWindow] = useState(false);
|
|
19
|
-
const [selectedPlaceMarker, setSelectedPlaceMarker] = useState(null);
|
|
20
|
-
|
|
21
|
-
const getRadiusForZoom = () => {
|
|
22
|
-
if (currentZoom >= 18) return 1000;
|
|
23
|
-
if (currentZoom <= 10) return 0;
|
|
24
|
-
|
|
25
|
-
let tempZoom = Math.pow(19 - currentZoom, 4.85);
|
|
26
|
-
let radius = tempZoom;
|
|
27
|
-
let minRadius = 1500;
|
|
28
|
-
let maxRadius = 800000;
|
|
29
|
-
|
|
30
|
-
if (radius < minRadius) radius = minRadius;
|
|
31
|
-
else if (radius > maxRadius) radius = maxRadius;
|
|
32
|
-
|
|
33
|
-
return radius;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (!selectedPlaces || (!selectedPlaces.length > 0) || !center || currentZoom < 12) {
|
|
38
|
-
setPoiMarkers({ markers: [], icon: null });
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const fetchPlaces = async () => {
|
|
42
|
-
let poiTypes = [];
|
|
43
|
-
const selectedPOICategories = selectedPlaces;
|
|
44
|
-
selectedPOICategories.forEach(pointOfInterest => {
|
|
45
|
-
poiTypes = poiTypes.concat(placeMappings[pointOfInterest]);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const radius = getRadiusForZoom();
|
|
49
|
-
const location = { latitude: currentCenter.lat, longitude: currentCenter.lng };
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const response = await searchNearbyPlaces(poiTypes, location, radius);
|
|
53
|
-
const newMarkers = response.places.map(place => {
|
|
54
|
-
const getParentCategory = types => {
|
|
55
|
-
const selectedTypes = selectedPOICategories.reduce((acc, category) => {
|
|
56
|
-
return acc.concat(placeMappings[category]);
|
|
57
|
-
}, []);
|
|
58
|
-
|
|
59
|
-
for (const type of types) {
|
|
60
|
-
if (!selectedTypes.includes(type)) continue;
|
|
61
|
-
for (const category in placeMappings) {
|
|
62
|
-
if (placeMappings[category].includes(type)) {
|
|
63
|
-
return category;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const icon = markerIconProps(markerColors.placeMarkers, getParentCategory(place.types));
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
position: { lat: place.location.latitude, lng: place.location.longitude },
|
|
74
|
-
title: place.displayName.text,
|
|
75
|
-
icon: icon
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
setPoiMarkers({ markers: newMarkers, icon: null });
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.error('Failed to fetch places:', error);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
fetchPlaces();
|
|
85
|
-
}, [selectedPlaces, currentZoom, currentCenter]);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<PlacesContext.Provider value={{
|
|
89
|
-
poiMarkers,
|
|
90
|
-
setCurrentCenter,
|
|
91
|
-
currentCenter,
|
|
92
|
-
setCurrentZoom,
|
|
93
|
-
currentZoom,
|
|
94
|
-
placesWindow,
|
|
95
|
-
setPlacesWindow,
|
|
96
|
-
selectedPlaceMarker,
|
|
97
|
-
setSelectedPlaceMarker
|
|
98
|
-
}}>
|
|
99
|
-
{children}
|
|
100
|
-
</PlacesContext.Provider>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
1
|
+
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { markerIconProps } from '~/util/mapIconUtil';
|
|
4
|
+
|
|
5
|
+
import { useMap } from '~/contexts/mapContext';
|
|
6
|
+
|
|
7
|
+
import { searchNearbyPlaces } from '~/services/googlePlacesNearbyService';
|
|
8
|
+
|
|
9
|
+
const PlacesContext = createContext();
|
|
10
|
+
|
|
11
|
+
export const usePlaces = () => useContext(PlacesContext);
|
|
12
|
+
|
|
13
|
+
export const PlacesProvider = ({ children, placeMappings, markerColors }) => {
|
|
14
|
+
const { selectedPlaces, zoom, center } = useMap();
|
|
15
|
+
const [poiMarkers, setPoiMarkers] = useState({ markers: [], icon: null });
|
|
16
|
+
const [currentCenter, setCurrentCenter] = useState(center);
|
|
17
|
+
const [currentZoom, setCurrentZoom] = useState(zoom);
|
|
18
|
+
const [placesWindow, setPlacesWindow] = useState(false);
|
|
19
|
+
const [selectedPlaceMarker, setSelectedPlaceMarker] = useState(null);
|
|
20
|
+
|
|
21
|
+
const getRadiusForZoom = () => {
|
|
22
|
+
if (currentZoom >= 18) return 1000;
|
|
23
|
+
if (currentZoom <= 10) return 0;
|
|
24
|
+
|
|
25
|
+
let tempZoom = Math.pow(19 - currentZoom, 4.85);
|
|
26
|
+
let radius = tempZoom;
|
|
27
|
+
let minRadius = 1500;
|
|
28
|
+
let maxRadius = 800000;
|
|
29
|
+
|
|
30
|
+
if (radius < minRadius) radius = minRadius;
|
|
31
|
+
else if (radius > maxRadius) radius = maxRadius;
|
|
32
|
+
|
|
33
|
+
return radius;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!selectedPlaces || (!selectedPlaces.length > 0) || !center || currentZoom < 12) {
|
|
38
|
+
setPoiMarkers({ markers: [], icon: null });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const fetchPlaces = async () => {
|
|
42
|
+
let poiTypes = [];
|
|
43
|
+
const selectedPOICategories = selectedPlaces;
|
|
44
|
+
selectedPOICategories.forEach(pointOfInterest => {
|
|
45
|
+
poiTypes = poiTypes.concat(placeMappings[pointOfInterest]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const radius = getRadiusForZoom();
|
|
49
|
+
const location = { latitude: currentCenter.lat, longitude: currentCenter.lng };
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const response = await searchNearbyPlaces(poiTypes, location, radius);
|
|
53
|
+
const newMarkers = response.places.map(place => {
|
|
54
|
+
const getParentCategory = types => {
|
|
55
|
+
const selectedTypes = selectedPOICategories.reduce((acc, category) => {
|
|
56
|
+
return acc.concat(placeMappings[category]);
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
for (const type of types) {
|
|
60
|
+
if (!selectedTypes.includes(type)) continue;
|
|
61
|
+
for (const category in placeMappings) {
|
|
62
|
+
if (placeMappings[category].includes(type)) {
|
|
63
|
+
return category;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const icon = markerIconProps(markerColors.placeMarkers, getParentCategory(place.types));
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
position: { lat: place.location.latitude, lng: place.location.longitude },
|
|
74
|
+
title: place.displayName.text,
|
|
75
|
+
icon: icon
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
setPoiMarkers({ markers: newMarkers, icon: null });
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error('Failed to fetch places:', error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
fetchPlaces();
|
|
85
|
+
}, [selectedPlaces, currentZoom, currentCenter]);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<PlacesContext.Provider value={{
|
|
89
|
+
poiMarkers,
|
|
90
|
+
setCurrentCenter,
|
|
91
|
+
currentCenter,
|
|
92
|
+
setCurrentZoom,
|
|
93
|
+
currentZoom,
|
|
94
|
+
placesWindow,
|
|
95
|
+
setPlacesWindow,
|
|
96
|
+
selectedPlaceMarker,
|
|
97
|
+
setSelectedPlaceMarker
|
|
98
|
+
}}>
|
|
99
|
+
{children}
|
|
100
|
+
</PlacesContext.Provider>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import { eventTypes } from '~/constants/eventTypes';
|
|
3
|
+
|
|
4
|
+
const TrackEventContext = createContext();
|
|
5
|
+
|
|
6
|
+
export const useTrackEvent = () => useContext(TrackEventContext);
|
|
7
|
+
|
|
8
|
+
export const TrackEventProvider = ({ children, trackEvent }) => {
|
|
9
|
+
return (
|
|
10
|
+
<TrackEventContext.Provider value={{ trackEvent, eventTypes }}>
|
|
11
|
+
{children}
|
|
12
|
+
</TrackEventContext.Provider>
|
|
13
|
+
);
|
|
14
|
+
};
|
package/src/hooks/useList.js
CHANGED
|
@@ -1,100 +1,89 @@
|
|
|
1
|
-
import { useEffect, useState, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { getStorageObject } from '~/util/localStorageUtil';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const [
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const handleScroll = () => {
|
|
92
|
-
if (scrollContainerRef.current) {
|
|
93
|
-
setScrollPosition(scrollContainerRef.current.scrollTop);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, dynamicSort, filteredListings };
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export default useListLogic;
|
|
1
|
+
import { useEffect, useState, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { getStorageObject } from '~/util/localStorageUtil';
|
|
4
|
+
|
|
5
|
+
const getDefaultItemId = () => {
|
|
6
|
+
let item = getStorageObject("selectedListItem");
|
|
7
|
+
if (item?.expanded == true) {
|
|
8
|
+
return item.id;
|
|
9
|
+
} else {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const useListLogic = filteredListings => {
|
|
15
|
+
const [itemLimit, setItemLimit] = useState(100);
|
|
16
|
+
const [expandedId] = useState(getDefaultItemId());
|
|
17
|
+
const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
|
|
18
|
+
const [scrollPosition, setScrollPosition] = useState(getStorageObject('scrollPosition', 0));
|
|
19
|
+
const loader = useRef(null);
|
|
20
|
+
const scrollContainerRef = useRef(null);
|
|
21
|
+
const itemRefs = useRef({});
|
|
22
|
+
const observer = useRef(null);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
observer.current = new IntersectionObserver(handleObserver, {
|
|
26
|
+
root: scrollContainerRef.current,
|
|
27
|
+
rootMargin: "100px 0px",
|
|
28
|
+
threshold: 0.5
|
|
29
|
+
});
|
|
30
|
+
const { current } = loader;
|
|
31
|
+
if (current) {
|
|
32
|
+
observer.current.observe(current);
|
|
33
|
+
}
|
|
34
|
+
return () => {
|
|
35
|
+
if (observer.current && current) {
|
|
36
|
+
observer.current.unobserve(current);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [filteredListings.length, itemLimit]);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
localStorage.setItem('scrollPosition', scrollPosition.toString());
|
|
44
|
+
}, [scrollPosition]);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const savedScrollPosition = scrollPosition;
|
|
48
|
+
if (parseInt(savedScrollPosition) > 3000) {
|
|
49
|
+
setItemLimit(savedScrollPosition / 10);
|
|
50
|
+
}
|
|
51
|
+
if (savedScrollPosition && scrollContainerRef.current) {
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
scrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);
|
|
54
|
+
}, 300);
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const { current } = scrollContainerRef;
|
|
60
|
+
if (current) {
|
|
61
|
+
current.addEventListener('scroll', handleScroll);
|
|
62
|
+
}
|
|
63
|
+
return () => {
|
|
64
|
+
if (current) {
|
|
65
|
+
current.removeEventListener('scroll', handleScroll);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
const handleObserver = entities => {
|
|
71
|
+
const target = entities[0];
|
|
72
|
+
if (!target.isIntersecting) return;
|
|
73
|
+
if (filteredListings.length > itemLimit) {
|
|
74
|
+
setItemLimit(prevLimit => prevLimit + 100);
|
|
75
|
+
} else if (observer.current) {
|
|
76
|
+
observer.current.disconnect();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const handleScroll = () => {
|
|
81
|
+
if (scrollContainerRef.current) {
|
|
82
|
+
setScrollPosition(scrollContainerRef.current.scrollTop);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, filteredListings };
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default useListLogic;
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import HireControlMap from '~/components/HireControlMap';
|
|
2
|
-
|
|
3
|
-
export { HireControlMap };
|
|
1
|
+
import HireControlMap from '~/components/HireControlMap';
|
|
2
|
+
|
|
3
|
+
export { HireControlMap };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import api from '~/apis/hcApi';
|
|
2
|
-
|
|
3
|
-
export const getMapConfig = async () => {
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
const response = await api.get(`/MapConfig`);
|
|
7
|
-
return response;
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error("Error retrieving map configuration:", error);
|
|
10
|
-
throw error;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
getMapConfig
|
|
16
|
-
};
|
|
1
|
+
import api from '~/apis/hcApi';
|
|
2
|
+
|
|
3
|
+
export const getMapConfig = async () => {
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const response = await api.get(`/MapConfig`);
|
|
7
|
+
return response;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error("Error retrieving map configuration:", error);
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
getMapConfig
|
|
16
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
export const searchNearbyPlaces = async (typesArray, location, radius) => {
|
|
2
|
-
const url = 'https://places.googleapis.com/v1/places:searchNearby';
|
|
3
|
-
const headers = {
|
|
4
|
-
'Content-Type': 'application/json',
|
|
5
|
-
'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY,
|
|
6
|
-
'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
|
|
7
|
-
};
|
|
8
|
-
const data = {
|
|
9
|
-
includedTypes: typesArray,
|
|
10
|
-
maxResultCount: 20,
|
|
11
|
-
locationRestriction: {
|
|
12
|
-
circle: {
|
|
13
|
-
center: location,
|
|
14
|
-
radius: radius
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const response = await fetch(url, {
|
|
21
|
-
method: 'POST',
|
|
22
|
-
headers: headers,
|
|
23
|
-
body: JSON.stringify(data)
|
|
24
|
-
});
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
27
|
-
}
|
|
28
|
-
return await response.json();
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error('Error making the Nearby Search request:', error);
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
1
|
+
export const searchNearbyPlaces = async (typesArray, location, radius) => {
|
|
2
|
+
const url = 'https://places.googleapis.com/v1/places:searchNearby';
|
|
3
|
+
const headers = {
|
|
4
|
+
'Content-Type': 'application/json',
|
|
5
|
+
'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY,
|
|
6
|
+
'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
|
|
7
|
+
};
|
|
8
|
+
const data = {
|
|
9
|
+
includedTypes: typesArray,
|
|
10
|
+
maxResultCount: 20,
|
|
11
|
+
locationRestriction: {
|
|
12
|
+
circle: {
|
|
13
|
+
center: location,
|
|
14
|
+
radius: radius
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(url, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: headers,
|
|
23
|
+
body: JSON.stringify(data)
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
27
|
+
}
|
|
28
|
+
return await response.json();
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error making the Nearby Search request:', error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -1,45 +1,50 @@
|
|
|
1
|
-
import { getListings } from '~/services/listingService';
|
|
2
|
-
import { getRecruiters } from '~/services/recruiterService';
|
|
3
|
-
import { getListingEntities } from '~/services/listingEntityService';
|
|
4
|
-
|
|
5
|
-
import { getDistinctItemsByProximity } from '~/util/mapUtil';
|
|
6
|
-
|
|
7
|
-
const fetchListings = async (query, siteConfig) => {
|
|
8
|
-
try {
|
|
9
|
-
const listingsResult = await getListings(
|
|
10
|
-
siteConfig.companyId,
|
|
11
|
-
5000,
|
|
12
|
-
1,
|
|
13
|
-
query
|
|
14
|
-
);
|
|
15
|
-
const recruiterIds = [
|
|
16
|
-
// eslint-disable-next-line no-undef
|
|
17
|
-
...new Set(listingsResult.map(listing => listing.recruiterId))
|
|
18
|
-
];
|
|
19
|
-
const fetchedRecruiters = await getRecruiters(recruiterIds);
|
|
20
|
-
|
|
21
|
-
const distinctEntityIds = [
|
|
22
|
-
// eslint-disable-next-line no-undef
|
|
23
|
-
...new Set(listingsResult.map(listing => listing.entityId))
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
listingsResult
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fetchedEntities
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import { getListings } from '~/services/listingService';
|
|
2
|
+
import { getRecruiters } from '~/services/recruiterService';
|
|
3
|
+
import { getListingEntities } from '~/services/listingEntityService';
|
|
4
|
+
|
|
5
|
+
import { getDistinctItemsByProximity } from '~/util/mapUtil';
|
|
6
|
+
|
|
7
|
+
const fetchListings = async (query, siteConfig, commuteLocation = null) => {
|
|
8
|
+
try {
|
|
9
|
+
const listingsResult = await getListings(
|
|
10
|
+
siteConfig.companyId,
|
|
11
|
+
5000,
|
|
12
|
+
1,
|
|
13
|
+
query
|
|
14
|
+
);
|
|
15
|
+
const recruiterIds = [
|
|
16
|
+
// eslint-disable-next-line no-undef
|
|
17
|
+
...new Set(listingsResult.map(listing => listing.recruiterId))
|
|
18
|
+
];
|
|
19
|
+
const fetchedRecruiters = await getRecruiters(recruiterIds);
|
|
20
|
+
|
|
21
|
+
const distinctEntityIds = [
|
|
22
|
+
// eslint-disable-next-line no-undef
|
|
23
|
+
...new Set(listingsResult.map(listing => listing.entityId))
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const fetchedEntities = !commuteLocation ? await getListingEntities(
|
|
27
|
+
distinctEntityIds) : await getListingEntities(
|
|
28
|
+
distinctEntityIds,`${commuteLocation.lat}, ${commuteLocation.lng}`);
|
|
29
|
+
for (var i = 0; i < listingsResult.length; i++) {
|
|
30
|
+
if (listingsResult[i].entityId != -1) {
|
|
31
|
+
listingsResult[i].fields.travelTime = fetchedEntities[listingsResult[i].entityId].travelTime;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const distinctItems = getDistinctItemsByProximity(
|
|
35
|
+
listingsResult,
|
|
36
|
+
fetchedEntities
|
|
37
|
+
);
|
|
38
|
+
return {
|
|
39
|
+
listingsResult,
|
|
40
|
+
fetchedRecruiters,
|
|
41
|
+
fetchedEntities,
|
|
42
|
+
distinctItems
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Error fetching listings:", error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default fetchListings;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import api from '~/apis/hcApi';
|
|
2
|
-
|
|
3
|
-
export const getListingEntities = async (entityIds, origin = '') => {
|
|
4
|
-
try {
|
|
5
|
-
const response = await api.post(`/ListingEntities?origin=${origin}`, entityIds);
|
|
6
|
-
return response;
|
|
7
|
-
} catch (error) {
|
|
8
|
-
console.error("Error fetching listing entities:", error);
|
|
9
|
-
throw error;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
getListingEntities
|
|
15
|
-
};
|
|
1
|
+
import api from '~/apis/hcApi';
|
|
2
|
+
|
|
3
|
+
export const getListingEntities = async (entityIds, origin = '') => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await api.post(`/ListingEntities?origin=${origin}`, entityIds);
|
|
6
|
+
return response;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error("Error fetching listing entities:", error);
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
getListingEntities
|
|
15
|
+
};
|