@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.
Files changed (166) hide show
  1. package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -1
  2. package/dist/apis/hcApi.js +1 -1
  3. package/dist/apis/hcApi.js.map +1 -1
  4. package/dist/clientToken.js.map +1 -1
  5. package/dist/components/HireControlMap.js +15 -5
  6. package/dist/components/HireControlMap.js.map +1 -1
  7. package/dist/components/modules/accordions/MapAccordionItem.js +11 -1
  8. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  9. package/dist/components/modules/accordions/default.js.map +1 -1
  10. package/dist/components/modules/accordions/filterItem.js +2 -1
  11. package/dist/components/modules/accordions/filterItem.js.map +1 -1
  12. package/dist/components/modules/accordions/filters.js +0 -3
  13. package/dist/components/modules/accordions/filters.js.map +1 -1
  14. package/dist/components/modules/buttons/button-group-apply.js +36 -15
  15. package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
  16. package/dist/components/modules/buttons/commute-pill.js.map +1 -1
  17. package/dist/components/modules/buttons/default.js.map +1 -1
  18. package/dist/components/modules/buttons/items-pill.js.map +1 -1
  19. package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
  20. package/dist/components/modules/buttons/show-all-button.js.map +1 -1
  21. package/dist/components/modules/cards/default.js.map +1 -1
  22. package/dist/components/modules/cards/filter.js.map +1 -1
  23. package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
  24. package/dist/components/modules/filter/commute.js +22 -6
  25. package/dist/components/modules/filter/commute.js.map +1 -1
  26. package/dist/components/modules/filter/index.js +7 -0
  27. package/dist/components/modules/filter/index.js.map +1 -1
  28. package/dist/components/modules/filter/item.js +16 -1
  29. package/dist/components/modules/filter/item.js.map +1 -1
  30. package/dist/components/modules/filter/location.js +1 -1
  31. package/dist/components/modules/filter/location.js.map +1 -1
  32. package/dist/components/modules/filter/points-of-interest.js.map +1 -1
  33. package/dist/components/modules/filter/radio-item.js +7 -0
  34. package/dist/components/modules/filter/radio-item.js.map +1 -1
  35. package/dist/components/modules/filter/search.js.map +1 -1
  36. package/dist/components/modules/filter/sort.js.map +1 -1
  37. package/dist/components/modules/grid.js.map +1 -1
  38. package/dist/components/modules/icon.js.map +1 -1
  39. package/dist/components/modules/jobListing/listing-details.js +6 -0
  40. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  41. package/dist/components/modules/maps/info-window-card.js.map +1 -1
  42. package/dist/components/modules/maps/info-window-content.js +20 -0
  43. package/dist/components/modules/maps/info-window-content.js.map +1 -1
  44. package/dist/components/modules/maps/list/field-mapper.js.map +1 -1
  45. package/dist/components/modules/maps/list/header-item.js.map +1 -1
  46. package/dist/components/modules/maps/list/header.js.map +1 -1
  47. package/dist/components/modules/maps/list/index.js +21 -12
  48. package/dist/components/modules/maps/list/index.js.map +1 -1
  49. package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
  50. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
  51. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
  52. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
  53. package/dist/components/modules/maps/list/list-item/index.js +12 -2
  54. package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
  55. package/dist/components/modules/maps/map-list.js.map +1 -1
  56. package/dist/components/modules/maps/map-marker.js +10 -0
  57. package/dist/components/modules/maps/map-marker.js.map +1 -1
  58. package/dist/components/modules/maps/map.js.map +1 -1
  59. package/dist/components/modules/maps/place-marker.js.map +1 -1
  60. package/dist/components/modules/maps/tabs.js.map +1 -1
  61. package/dist/constants/eventTypes.js +16 -0
  62. package/dist/constants/eventTypes.js.map +1 -0
  63. package/dist/constants/placeTypes.js.map +1 -1
  64. package/dist/contexts/mapContext.js +9 -27
  65. package/dist/contexts/mapContext.js.map +1 -1
  66. package/dist/contexts/mapListContext.js +57 -38
  67. package/dist/contexts/mapListContext.js.map +1 -1
  68. package/dist/contexts/placesContext.js.map +1 -1
  69. package/dist/contexts/trackEventContext.js +20 -0
  70. package/dist/contexts/trackEventContext.js.map +1 -0
  71. package/dist/hooks/useList.js +1 -13
  72. package/dist/hooks/useList.js.map +1 -1
  73. package/dist/services/apis/hcApi.js +1 -1
  74. package/dist/services/apis/hcApi.js.map +1 -1
  75. package/dist/services/clientToken.js.map +1 -1
  76. package/dist/services/configService.js.map +1 -1
  77. package/dist/services/googlePlacesNearbyService.js.map +1 -1
  78. package/dist/services/listingAggregatorService.js +43 -16
  79. package/dist/services/listingAggregatorService.js.map +1 -1
  80. package/dist/services/listingEntityService.js.map +1 -1
  81. package/dist/services/listingService.js.map +1 -1
  82. package/dist/services/recruiterService.js.map +1 -1
  83. package/dist/util/filterUtil.js.map +1 -1
  84. package/dist/util/loading.js.map +1 -1
  85. package/dist/util/localStorageUtil.js.map +1 -1
  86. package/dist/util/mapIconUtil.js.map +1 -1
  87. package/dist/util/mapUtil.js.map +1 -1
  88. package/dist/util/sortUtil.js.map +1 -1
  89. package/dist/util/stringUtils.js.map +1 -1
  90. package/jsconfig.json +7 -7
  91. package/package.json +60 -60
  92. package/postcss.config.js +13 -13
  93. package/preset.default.js +15 -15
  94. package/rollup.config.mjs +88 -87
  95. package/src/apis/hcApi.js +93 -93
  96. package/src/clientToken.js +9 -9
  97. package/src/components/HireControlMap.js +129 -124
  98. package/src/components/modules/accordions/MapAccordionItem.js +74 -72
  99. package/src/components/modules/accordions/default.js +171 -171
  100. package/src/components/modules/accordions/filterItem.js +55 -53
  101. package/src/components/modules/accordions/filters.js +47 -47
  102. package/src/components/modules/buttons/button-group-apply.js +123 -116
  103. package/src/components/modules/buttons/commute-pill.js +22 -22
  104. package/src/components/modules/buttons/default.js +194 -194
  105. package/src/components/modules/buttons/items-pill.js +35 -35
  106. package/src/components/modules/buttons/pill-wrapper.js +27 -27
  107. package/src/components/modules/buttons/show-all-button.js +20 -20
  108. package/src/components/modules/cards/default.js +167 -167
  109. package/src/components/modules/cards/filter.js +56 -56
  110. package/src/components/modules/dialogs/apply-dialog.js +48 -48
  111. package/src/components/modules/filter/commute.js +154 -149
  112. package/src/components/modules/filter/index.js +89 -87
  113. package/src/components/modules/filter/item.js +87 -76
  114. package/src/components/modules/filter/location.js +71 -71
  115. package/src/components/modules/filter/points-of-interest.js +44 -44
  116. package/src/components/modules/filter/radio-item.js +57 -53
  117. package/src/components/modules/filter/search.js +92 -92
  118. package/src/components/modules/filter/sort.js +83 -83
  119. package/src/components/modules/grid.js +54 -54
  120. package/src/components/modules/icon.js +33 -33
  121. package/src/components/modules/jobListing/listing-details.js +99 -95
  122. package/src/components/modules/maps/info-window-card.js +17 -17
  123. package/src/components/modules/maps/info-window-content.js +81 -74
  124. package/src/components/modules/maps/list/field-mapper.js +112 -112
  125. package/src/components/modules/maps/list/header-item.js +91 -91
  126. package/src/components/modules/maps/list/header.js +47 -47
  127. package/src/components/modules/maps/list/index.js +112 -107
  128. package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
  129. package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
  130. package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
  131. package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
  132. package/src/components/modules/maps/list/list-item/index.js +135 -133
  133. package/src/components/modules/maps/map-list.js +74 -74
  134. package/src/components/modules/maps/map-marker.js +88 -86
  135. package/src/components/modules/maps/map.js +230 -230
  136. package/src/components/modules/maps/place-marker.js +41 -41
  137. package/src/components/modules/maps/tabs.js +81 -81
  138. package/src/constants/eventTypes.js +13 -0
  139. package/src/constants/placeTypes.js +8 -8
  140. package/src/contexts/mapContext.js +101 -115
  141. package/src/contexts/mapListContext.js +242 -222
  142. package/src/contexts/placesContext.js +102 -102
  143. package/src/contexts/trackEventContext.js +14 -0
  144. package/src/hooks/useList.js +89 -100
  145. package/src/index.js +3 -3
  146. package/src/services/configService.js +16 -16
  147. package/src/services/googlePlacesNearbyService.js +33 -33
  148. package/src/services/listingAggregatorService.js +50 -45
  149. package/src/services/listingEntityService.js +15 -15
  150. package/src/services/listingService.js +26 -26
  151. package/src/services/recruiterService.js +17 -17
  152. package/src/styles/index.css +23 -23
  153. package/src/util/arrayUtil.js +3 -3
  154. package/src/util/fieldMapper.js +22 -22
  155. package/src/util/filterUtil.js +195 -195
  156. package/src/util/loading.js +17 -17
  157. package/src/util/localStorageUtil.js +26 -26
  158. package/src/util/mapIconUtil.js +180 -180
  159. package/src/util/mapUtil.js +91 -91
  160. package/src/util/sortUtil.js +32 -32
  161. package/src/util/stringUtils.js +6 -6
  162. package/src/util/urlFilterUtil.js +90 -90
  163. package/tailwind.config.js +126 -126
  164. package/.editorconfig +0 -12
  165. package/.eslintrc +0 -105
  166. 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
+ };
@@ -1,100 +1,89 @@
1
- import { useEffect, useState, useRef } from 'react';
2
-
3
- import { getStorageObject } from '~/util/localStorageUtil';
4
- import { dynamicSort } from '~/util/sortUtil';
5
-
6
- import { useMapList } from '~/contexts/mapListContext';
7
-
8
- const getDefaultItemId = () => {
9
- let item = getStorageObject("selectedListItem");
10
- if (item?.expanded == true) {
11
- return item.id;
12
- } else {
13
- return null;
14
- }
15
- };
16
-
17
- const useListLogic = () => {
18
- const [itemLimit, setItemLimit] = useState(100);
19
- const [expandedId] = useState(getDefaultItemId());
20
- const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
21
- const [scrollPosition, setScrollPosition] = useState(getStorageObject('scrollPosition', 0));
22
- const loader = useRef(null);
23
- const scrollContainerRef = useRef(null);
24
- const itemRefs = useRef({});
25
- const observer = useRef(null);
26
- const { filteredListings, setFilteredListings } = useMapList();
27
-
28
- useEffect(() => {
29
- if (!sortSetting) return;
30
- localStorage.setItem('sortSetting', JSON.stringify(sortSetting));
31
- let listingFiltered = dynamicSort(filteredListings, sortSetting.field, sortSetting.type);
32
- setFilteredListings(listingFiltered);
33
- }, [sortSetting]);
34
-
35
- useEffect(() => {
36
- observer.current = new IntersectionObserver(handleObserver, {
37
- root: scrollContainerRef.current,
38
- rootMargin: "100px 0px",
39
- threshold: 0.5
40
- });
41
- const { current } = loader;
42
- if (current) {
43
- observer.current.observe(current);
44
- }
45
- return () => {
46
- if (observer.current && current) {
47
- observer.current.unobserve(current);
48
- }
49
- };
50
- // eslint-disable-next-line react-hooks/exhaustive-deps
51
- }, [filteredListings.length, itemLimit]);
52
-
53
- useEffect(() => {
54
- localStorage.setItem('scrollPosition', scrollPosition.toString());
55
- }, [scrollPosition]);
56
-
57
- useEffect(() => {
58
- const savedScrollPosition = scrollPosition;
59
- if (parseInt(savedScrollPosition) > 3000) {
60
- setItemLimit(savedScrollPosition / 10);
61
- }
62
- if (savedScrollPosition && scrollContainerRef.current) {
63
- setTimeout(() => {
64
- scrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);
65
- }, 300);
66
- }
67
- }, []);
68
-
69
- useEffect(() => {
70
- const { current } = scrollContainerRef;
71
- if (current) {
72
- current.addEventListener('scroll', handleScroll);
73
- }
74
- return () => {
75
- if (current) {
76
- current.removeEventListener('scroll', handleScroll);
77
- }
78
- };
79
- }, []);
80
-
81
- const handleObserver = entities => {
82
- const target = entities[0];
83
- if (!target.isIntersecting) return;
84
- if (filteredListings.length > itemLimit) {
85
- setItemLimit(prevLimit => prevLimit + 100);
86
- } else if (observer.current) {
87
- observer.current.disconnect();
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
- const fetchedEntities = await getListingEntities(
26
- distinctEntityIds
27
- );
28
-
29
- const distinctItems = getDistinctItemsByProximity(
30
- listingsResult,
31
- fetchedEntities
32
- );
33
- return {
34
- listingsResult,
35
- fetchedRecruiters,
36
- fetchedEntities,
37
- distinctItems
38
- };
39
- } catch (error) {
40
- console.error("Error fetching listings:", error);
41
- throw error;
42
- }
43
- };
44
-
45
- export default fetchListings;
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
+ };