@abcagency/hc-ui-components 1.3.17 → 1.3.19

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 (196) hide show
  1. package/dist/apis/hcApi.js +85 -183
  2. package/dist/apis/hcApi.js.map +1 -1
  3. package/dist/components/HireControlMap.js +10 -5
  4. package/dist/components/HireControlMap.js.map +1 -1
  5. package/dist/components/modules/accordions/MapAccordionItem.js +10 -67
  6. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  7. package/dist/components/modules/filter/index.js.map +1 -1
  8. package/dist/components/modules/filter/radio-item.js +1 -2
  9. package/dist/components/modules/filter/radio-item.js.map +1 -1
  10. package/dist/components/modules/filter/search.js +4 -4
  11. package/dist/components/modules/filter/search.js.map +1 -1
  12. package/dist/components/modules/jobListing/listing-details-container.js +45 -0
  13. package/dist/components/modules/jobListing/listing-details-container.js.map +1 -0
  14. package/dist/components/modules/jobListing/listing-details.js +24 -24
  15. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  16. package/dist/components/modules/{maps/list → list}/field-mapper.js +8 -7
  17. package/dist/components/modules/list/field-mapper.js.map +1 -0
  18. package/dist/components/modules/{maps/list → list}/header-item.js +2 -2
  19. package/dist/components/modules/list/header-item.js.map +1 -0
  20. package/dist/components/modules/{maps/list → list}/header.js +6 -4
  21. package/dist/components/modules/list/header.js.map +1 -0
  22. package/dist/components/modules/list/index.js +36 -0
  23. package/dist/components/modules/list/index.js.map +1 -0
  24. package/dist/components/modules/{maps/list → list}/item-expand-card/index.js +3 -1
  25. package/dist/components/modules/list/item-expand-card/index.js.map +1 -0
  26. package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +2 -2
  27. package/dist/components/modules/list/item-expand-card/recruiter-contact-nav.js.map +1 -0
  28. package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +1 -1
  29. package/dist/components/modules/list/item-expand-card/recruiter-details.js.map +1 -0
  30. package/dist/components/modules/list/item-expand-card/recruiter-headshot.js.map +1 -0
  31. package/dist/components/modules/list/item-list.js +28 -0
  32. package/dist/components/modules/list/item-list.js.map +1 -0
  33. package/dist/components/modules/list/list-item/index.js +75 -0
  34. package/dist/components/modules/list/list-item/index.js.map +1 -0
  35. package/dist/components/modules/list/list-item/list-item-container.js +47 -0
  36. package/dist/components/modules/list/list-item/list-item-container.js.map +1 -0
  37. package/dist/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +29 -33
  38. package/dist/components/modules/list/list-item/list-item.js.map +1 -0
  39. package/dist/components/modules/maps/map-list.js +3 -3
  40. package/dist/components/modules/maps/map-list.js.map +1 -1
  41. package/dist/constants/eventTypes.js +1 -1
  42. package/dist/constants/eventTypes.js.map +1 -1
  43. package/dist/contexts/mapContext.js +84 -113
  44. package/dist/contexts/mapContext.js.map +1 -1
  45. package/dist/contexts/mapListContext.js +181 -290
  46. package/dist/contexts/mapListContext.js.map +1 -1
  47. package/dist/contexts/trackEventContext.js +1 -1
  48. package/dist/services/configService.js +10 -28
  49. package/dist/services/configService.js.map +1 -1
  50. package/dist/services/googlePlacesNearbyService.js +33 -58
  51. package/dist/services/googlePlacesNearbyService.js.map +1 -1
  52. package/dist/services/listingAggregatorService.js +35 -75
  53. package/dist/services/listingAggregatorService.js.map +1 -1
  54. package/dist/services/listingEntityService.js +10 -31
  55. package/dist/services/listingEntityService.js.map +1 -1
  56. package/dist/services/listingService.js +26 -60
  57. package/dist/services/listingService.js.map +1 -1
  58. package/dist/services/recruiterService.js +11 -31
  59. package/dist/services/recruiterService.js.map +1 -1
  60. package/dist/types/apis/hcApi.d.ts +5 -0
  61. package/dist/types/clientToken.d.ts +2 -0
  62. package/dist/types/components/modules/accordions/MapAccordionItem.d.ts +9 -0
  63. package/dist/types/components/modules/accordions/default.d.ts +19 -0
  64. package/dist/types/components/modules/buttons/button-group-apply.d.ts +24 -0
  65. package/dist/types/components/modules/buttons/commute-pill.d.ts +5 -0
  66. package/dist/types/components/modules/buttons/default.d.ts +48 -0
  67. package/dist/types/components/modules/buttons/pill-wrapper.d.ts +3 -0
  68. package/dist/types/components/modules/dialogs/apply-dialog.d.ts +8 -0
  69. package/dist/types/components/modules/filter/sort.d.ts +8 -0
  70. package/dist/types/components/modules/grid.d.ts +8 -0
  71. package/dist/types/components/modules/icon.d.ts +10 -0
  72. package/dist/types/components/modules/jobListing/listing-details-container.d.ts +6 -0
  73. package/dist/types/components/modules/jobListing/listing-details.d.ts +18 -0
  74. package/dist/types/components/modules/list/field-mapper.d.ts +10 -0
  75. package/dist/types/components/modules/list/header-item.d.ts +11 -0
  76. package/dist/types/components/modules/list/header.d.ts +11 -0
  77. package/dist/types/components/modules/list/index.d.ts +9 -0
  78. package/dist/types/components/modules/list/item-expand-card/index.d.ts +7 -0
  79. package/dist/types/components/modules/list/item-expand-card/recruiter-contact-nav.d.ts +17 -0
  80. package/dist/types/components/modules/list/item-expand-card/recruiter-details.d.ts +21 -0
  81. package/dist/types/components/modules/list/item-expand-card/recruiter-headshot.d.ts +8 -0
  82. package/dist/types/components/modules/list/item-list.d.ts +21 -0
  83. package/dist/types/components/modules/list/list-item/index.d.ts +12 -0
  84. package/dist/types/components/modules/list/list-item/list-item-container.d.ts +14 -0
  85. package/dist/types/components/modules/list/list-item/list-item.d.ts +3 -0
  86. package/dist/types/constants/eventTypes.d.ts +13 -0
  87. package/dist/types/contexts/mapContext.d.ts +29 -0
  88. package/dist/types/contexts/mapListContext.d.ts +58 -0
  89. package/dist/types/contexts/trackEventContext.d.ts +6 -0
  90. package/dist/types/enums/SectionType.d.ts +9 -0
  91. package/dist/types/hooks/useList.d.ts +13 -0
  92. package/dist/types/services/configService.d.ts +6 -0
  93. package/dist/types/services/googlePlacesNearbyService.d.ts +5 -0
  94. package/dist/types/services/listingAggregatorService.d.ts +12 -0
  95. package/dist/types/services/listingEntityService.d.ts +6 -0
  96. package/dist/types/services/listingService.d.ts +9 -0
  97. package/dist/types/services/recruiterService.d.ts +6 -0
  98. package/dist/types/types/Address.d.ts +7 -0
  99. package/dist/types/types/ContentSection.d.ts +8 -0
  100. package/dist/types/types/GetListingParams.d.ts +8 -0
  101. package/dist/types/types/LatLng.d.ts +4 -0
  102. package/dist/types/types/ListingEntity.d.ts +10 -0
  103. package/dist/types/types/ListingFields.d.ts +20 -0
  104. package/dist/types/types/Listings.d.ts +31 -0
  105. package/dist/types/types/Recruiter.d.ts +9 -0
  106. package/dist/types/types/SimilarListing.d.ts +24 -0
  107. package/dist/types/types/config/Colors.d.ts +8 -0
  108. package/dist/types/types/config/MapConfig.d.ts +29 -0
  109. package/dist/types/types/config/PointsOfInterestConfig.d.ts +13 -0
  110. package/dist/types/types/config/SearchConfig.d.ts +4 -0
  111. package/dist/types/util/filterUtil.d.ts +28 -0
  112. package/dist/types/util/loading.d.ts +3 -0
  113. package/dist/types/util/localStorageUtil.d.ts +3 -0
  114. package/dist/types/util/mapUtil.d.ts +15 -0
  115. package/dist/types/util/sortUtil.d.ts +1 -0
  116. package/dist/types/util/stringUtils.d.ts +1 -0
  117. package/dist/util/filterUtil.js +34 -10
  118. package/dist/util/filterUtil.js.map +1 -1
  119. package/dist/util/localStorageUtil.js +37 -28
  120. package/dist/util/localStorageUtil.js.map +1 -1
  121. package/dist/util/mapUtil.js.map +1 -1
  122. package/package.json +22 -14
  123. package/rollup.config.mjs +23 -19
  124. package/src/apis/{hcApi.js → hcApi.ts} +27 -11
  125. package/src/components/HireControlMap.js +132 -129
  126. package/src/components/modules/accordions/MapAccordionItem.js +32 -74
  127. package/src/components/modules/filter/index.js +89 -89
  128. package/src/components/modules/filter/radio-item.js +0 -1
  129. package/src/components/modules/filter/search.js +93 -92
  130. package/src/components/modules/jobListing/listing-details-container.js +40 -0
  131. package/src/components/modules/jobListing/listing-details.js +209 -99
  132. package/src/components/modules/{maps/list → list}/field-mapper.js +114 -112
  133. package/src/components/modules/{maps/list → list}/header.js +49 -47
  134. package/src/components/modules/list/index.tsx +83 -0
  135. package/src/components/modules/{maps/list → list}/item-expand-card/index.js +24 -22
  136. package/src/components/modules/list/item-list.tsx +198 -0
  137. package/src/components/modules/list/list-item/index.js +70 -0
  138. package/src/components/modules/list/list-item/list-item-container.js +43 -0
  139. package/src/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +129 -135
  140. package/src/components/modules/maps/map-list.js +74 -74
  141. package/src/constants/eventTypes.js +13 -13
  142. package/src/contexts/mapContext.tsx +129 -0
  143. package/src/contexts/mapListContext.tsx +297 -0
  144. package/src/enums/SectionType.ts +9 -0
  145. package/src/services/{configService.js → configService.ts} +16 -16
  146. package/src/services/{googlePlacesNearbyService.js → googlePlacesNearbyService.ts} +11 -2
  147. package/src/services/listingAggregatorService.ts +76 -0
  148. package/src/services/listingEntityService.ts +16 -0
  149. package/src/services/listingService.ts +40 -0
  150. package/src/services/{recruiterService.js → recruiterService.ts} +18 -17
  151. package/src/types/Address.ts +7 -0
  152. package/src/types/ContentSection.ts +9 -0
  153. package/src/types/GetListingParams.ts +8 -0
  154. package/src/types/LatLng.ts +4 -0
  155. package/src/types/ListingEntity.ts +11 -0
  156. package/src/types/ListingFields.ts +20 -0
  157. package/src/types/Listings.ts +32 -0
  158. package/src/types/Recruiter.ts +9 -0
  159. package/src/types/SimilarListing.ts +24 -0
  160. package/src/types/config/Colors.ts +8 -0
  161. package/src/types/config/MapConfig.ts +30 -0
  162. package/src/types/config/PointsOfInterestConfig.ts +13 -0
  163. package/src/types/config/SearchConfig.ts +4 -0
  164. package/src/util/filterUtil.js +50 -6
  165. package/src/util/localStorageUtil.ts +34 -0
  166. package/src/util/mapUtil.js +91 -91
  167. package/tsconfig.json +23 -0
  168. package/dist/components/modules/maps/list/field-mapper.js.map +0 -1
  169. package/dist/components/modules/maps/list/header-item.js.map +0 -1
  170. package/dist/components/modules/maps/list/header.js.map +0 -1
  171. package/dist/components/modules/maps/list/index.js +0 -102
  172. package/dist/components/modules/maps/list/index.js.map +0 -1
  173. package/dist/components/modules/maps/list/item-expand-card/index.js.map +0 -1
  174. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +0 -1
  175. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +0 -1
  176. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +0 -1
  177. package/dist/components/modules/maps/list/list-item/index.js.map +0 -1
  178. package/dist/services/_virtual/_rollupPluginBabelHelpers.js +0 -372
  179. package/dist/services/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  180. package/dist/services/apis/hcApi.js +0 -189
  181. package/dist/services/apis/hcApi.js.map +0 -1
  182. package/dist/services/clientToken.js +0 -7
  183. package/dist/services/clientToken.js.map +0 -1
  184. package/dist/services/styles/index.css +0 -3
  185. package/src/components/modules/maps/list/index.js +0 -112
  186. package/src/contexts/mapContext.js +0 -101
  187. package/src/contexts/mapListContext.js +0 -242
  188. package/src/services/listingAggregatorService.js +0 -50
  189. package/src/services/listingEntityService.js +0 -15
  190. package/src/services/listingService.js +0 -26
  191. package/src/util/localStorageUtil.js +0 -27
  192. /package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
  193. /package/src/components/modules/{maps/list → list}/header-item.js +0 -0
  194. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +0 -0
  195. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +0 -0
  196. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
@@ -1,112 +0,0 @@
1
- import React from 'react';
2
-
3
- import Accordion from '~/components/modules/accordions/default';
4
- import Header from '~/components/modules/maps/list/header';
5
- import MapAccordionItem from '~/components/modules/accordions/MapAccordionItem';
6
- import Sort from '~/components/modules/filter/sort';
7
- import ListingDetails from '~/components/modules/jobListing/listing-details';
8
-
9
- import useListLogic from '~/hooks/useList';
10
-
11
- import Loading from "~/util/loading";
12
-
13
- import { useMap } from '~/contexts/mapContext';
14
- import { useMapList } from '~/contexts/mapListContext';
15
- import { useTrackEvent } from '~/contexts/trackEventContext';
16
-
17
- import { dynamicSort } from '~/util/sortUtil';
18
-
19
- const ItemsList = ({
20
- fieldNames,
21
- showMap,
22
- fieldsShown,
23
- specialFeatures
24
- }) => {
25
- const { mapItems, filteredListings, loading, commuteLocation, sortSetting, setSortSetting } = useMapList();
26
- const {
27
- itemLimit,
28
- loader,
29
- scrollContainerRef,
30
- itemRefs
31
- } = useListLogic(filteredListings);
32
- const { selectedListItem } = useMap();
33
- const { trackEvent, eventTypes } = useTrackEvent();
34
- const itemExpandedContent = (item, recruiters) =>
35
- item ? <ListingDetails item={item} recruiters={recruiters} /> : null;
36
- if (!fieldsShown.includes('travelTime') && commuteLocation != null && Object.entries(commuteLocation).length > 0) {
37
- fieldsShown.push('travelTime');
38
- fieldNames['travelTime'] = 'Commute';
39
- } else if (fieldsShown.includes('travelTime') && !commuteLocation) {
40
- fieldsShown = fieldsShown.filter(x => x !== 'travelTime');
41
- }
42
-
43
- const setTrackedSortSetting = sortSetting => {
44
- trackEvent(eventTypes.LIST_SORTED, sortSetting);
45
- setSortSetting(sortSetting);
46
- };
47
- return (
48
- <div className="hc-relative hc-bg-white md:hc-px-4 hc-flex hc-flex-col">
49
- <div className="hc-flex hc-flex-wrap hc-items-center hc-justify-between hc-gap-4 md:hc-mb-2 hc-p-3 md:hc-p-0 hc-bg-uiAccent/10 md:hc-bg-transparent hc-border-b md:hc-border-none hc-border-uiAccent/20">
50
- <h2 className="hc-text-gray-500 hc-font-semibold hc-text-xs md:hc-text-sm">
51
- {loading &&
52
- <span>Loading...</span>
53
- }
54
- {!loading &&
55
- <span>{filteredListings.length} results</span>
56
- }
57
- </h2>
58
- <div className="hc-block md:hc-hidden">
59
- <Sort
60
- fields={fieldsShown}
61
- setSortSetting={setTrackedSortSetting}
62
- fieldNames={fieldNames}
63
- />
64
- </div>
65
- </div>
66
- <div>
67
- <Header
68
- setSortSetting={setTrackedSortSetting}
69
- sortSetting={sortSetting}
70
- fieldsShown={fieldsShown}
71
- fieldNames={fieldNames}
72
- />
73
- </div>
74
- <div
75
- ref={scrollContainerRef}
76
- className={`
77
- hc-flex-grow hc-overflow-y-auto
78
- ${showMap ? "md:hc-max-h-45vh hc-max-h-[100vh]" : "md:hc-max-h-95vh hc-max-h-[95vh]"}
79
- `}
80
- >
81
- {loading ? (
82
- <div className="hc-flex hc-justify-center hc-items-center hc-pt-20">
83
- <Loading />
84
- </div>
85
- ) : (
86
- <Accordion className="hc-divide-y hc-divide-uiAccent/10 hc-z-[1000]" defaultValue={selectedListItem?.id}>
87
- {(sortSetting ? dynamicSort(filteredListings, sortSetting.field, sortSetting.type) : filteredListings).slice(0, itemLimit).map(item => {
88
- return (<MapAccordionItem
89
- key={item.id}
90
- showMap={showMap}
91
- item={item}
92
- itemRefs={itemRefs}
93
- fieldsShown={fieldsShown}
94
- itemExpandedContent={itemExpandedContent}
95
- specialFeatures={specialFeatures}
96
- mapItems={mapItems}
97
- isActive={selectedListItem?.id == item.id}
98
- hasListItemSelected={selectedListItem != null}
99
- />
100
- );
101
- })}
102
- </Accordion>
103
- )}
104
- <div ref={loader} style={{ height: "100px", textAlign: "center" }}>
105
- {filteredListings.length >= itemLimit && <Loading />}
106
- </div>
107
- </div>
108
- </div>
109
- );
110
- };
111
-
112
- export default ItemsList;
@@ -1,101 +0,0 @@
1
- import React, { createContext, useState, useContext, useEffect, useRef } from 'react';
2
- import { getStorageObject, setStorageObject } from '~/util/localStorageUtil';
3
-
4
- const MapContext = createContext();
5
-
6
- export const useMap = () => {
7
- const context = useContext(MapContext);
8
- if (!context) {
9
- throw new Error("useMap must be used within a MapProvider");
10
- }
11
- return context;
12
- };
13
-
14
- export const MapProvider = ({ children, resetFilters }) => {
15
- const [selectedListItem, setSelectedListItem] = useState(getStorageObject('selectedListItem'));
16
- const [location, setLocation] = useState(getStorageObject('location'));
17
- const [center, setCenter] = useState(getStorageObject("center", { lat: 39.8283, lng: -98.5795 }));
18
- const [zoom, setZoom] = useState(getStorageObject("zoom", 10));
19
- const [selectedPlaces, setSelectedPlaces] = useState([]);
20
- const [mapInteracted, setMapInteracted] = useState(false);
21
- const [firstLoadListItem] = useState(getStorageObject('selectedListItem') ?? { id: "defaultId" });
22
- const userSetZoom = useRef(true);
23
-
24
- useEffect(() => {
25
- setStorageObject("selectedListItem", selectedListItem);
26
- }, [selectedListItem]);
27
-
28
- useEffect(() => {
29
- localStorage.setItem("zoom", zoom);
30
- }, [zoom]);
31
-
32
- useEffect(() => {
33
- if (location == null) {
34
- localStorage.removeItem("location");
35
- } else {
36
- setStorageObject("location", location);
37
- }
38
- }, [location]);
39
-
40
- useEffect(() => {
41
- setStorageObject("center", center);
42
- }, [center]);
43
-
44
- const selectItem = (item, itemLocation, zoom, center) => {
45
- setSelectedListItem(item);
46
- if (mapInteracted === false && itemLocation != null) {
47
- setLocation(itemLocation);
48
- }
49
- if (mapInteracted === false || itemLocation != null) {
50
- setLocation(itemLocation);
51
- setCenter(center);
52
- }
53
- if (mapInteracted === false) {
54
- setZoom(zoom);
55
-
56
- }
57
- };
58
-
59
- const filterReset = () => {
60
- setSelectedPlaces({});
61
- setSelectedListItem(null);
62
- setLocation(null);
63
- setZoom(8);
64
- setMapInteracted(false);
65
- };
66
-
67
- if (resetFilters === true) {
68
- filterReset();
69
- }
70
- const selectLocationEntity = location => {
71
-
72
- localStorage.removeItem("selectedListItem");
73
- setTimeout(() => setLocation(location), 200);
74
- setSelectedListItem(null);
75
- };
76
-
77
- return (
78
- <MapContext.Provider
79
- value={{
80
- selectedListItem,
81
- setSelectedListItem,
82
- location,
83
- center,
84
- zoom,
85
- setZoom,
86
- selectItem,
87
- setSelectedPlaces,
88
- selectedPlaces,
89
- selectLocationEntity,
90
- setLocation,
91
- setMapInteracted,
92
- mapInteracted,
93
- userSetZoom,
94
- firstLoadListItem,
95
- filterReset
96
- }}
97
- >
98
- {children}
99
- </MapContext.Provider>
100
- );
101
- };
@@ -1,242 +0,0 @@
1
- import React, { createContext, useState, useEffect, useContext } from 'react';
2
-
3
- import { generateFilterOptions, applyFilters, filterListingsByLocation } from '~/util/filterUtil';
4
- import { getStorageObject, setStorageObject } from '~/util/localStorageUtil';
5
-
6
- import { getListingEntities } from "~/services/listingEntityService";
7
- import fetchListings from '~/services/listingAggregatorService';
8
-
9
- const MapListContext = createContext();
10
-
11
- export const useMapList = () => useContext(MapListContext);
12
-
13
- const getQuery = () => {
14
- let query;
15
- //if (!hasQueryInUrl(location)) {
16
- query = typeof window !== 'undefined' ? localStorage.getItem('query') : '';
17
- // }
18
- //else {
19
- // query = filtersFromURL(location).query;
20
- // }
21
- return query;
22
- };
23
-
24
- export const MapListProvider = ({
25
- children,
26
- siteConfig,
27
- resetFilters,
28
- navigateToDetails,
29
- navigateToEasyApply,
30
- Link,
31
- linkFormat,
32
- trackEvent
33
- }) => {
34
- // const location = useLocation();
35
- // const navigate = useNavigate();
36
- const [allListings, setAllListings] = useState(getStorageObject("listings", []));
37
- const [filteredListings, setFilteredListings] = useState([]);
38
- const [loading, setLoading] = useState(false);
39
- const [mapItems, setMapItems] = useState(getStorageObject('mapItems', []));
40
- const [query, setQuery] = useState(() => resetFilters ? null : getQuery());
41
- const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
42
- const [listingEntities, setListingEntities] = useState(getStorageObject("listingEntities", null));
43
- const [firstLoad, setFirstLoad] = useState(true);
44
- const [commuteLocation, setCommuteLocation] = useState(getStorageObject('commuteLocation'));
45
- const [selectedFilters, setSelectedFilters] = useState(() => resetFilters ? {} : getStorageObject('selectedFilters', {}));//hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
46
- const [filterOptions, setFilterOptions] = useState();
47
- const [recruiters, setRecruiters] = useState(getStorageObject("recruiters", {}));
48
- const [filterDialogIsOpen, setFilterDialogIsOpen] = useState(false);
49
- const [mobileTab, setMobileTab] = useState("listTab");
50
- const [favorites, setFavorites] = useState([]);
51
- const [filterByFavorites, setFilterByFavorites] = useState(false);
52
-
53
- const setNewFilteredListings = filteredListings =>{
54
- setFilteredListings(filteredListings);
55
- };
56
-
57
- useEffect(() => {
58
- if (!sortSetting) return;
59
- localStorage.setItem('sortSetting', JSON.stringify(sortSetting));
60
- setNewFilteredListings(filteredListings);
61
- }, [sortSetting]);
62
-
63
- useEffect(() => {
64
- const loadedFavorites = JSON.parse(localStorage.getItem('favorites')) || [];
65
- setFavorites(loadedFavorites);
66
- }, []);
67
-
68
- useEffect(() => {
69
- setStorageObject("commuteLocation", commuteLocation);
70
- }, [commuteLocation]);
71
-
72
- useEffect(() => {
73
- if (commuteLocation === null || commuteLocation === '') return;
74
- async function fetchEntities() {
75
- const distinctEntityIds = [
76
- // eslint-disable-next-line no-undef
77
- ...new Set(allListings.map(listing => listing.entityId))
78
- ];
79
- try {
80
- const fetchedEntities = await getListingEntities(
81
- distinctEntityIds,
82
- `${commuteLocation.lat}, ${commuteLocation.lng}`
83
- );
84
- setListingEntities(fetchedEntities);
85
- var newFilteredListings = filteredListings;
86
- for (var i = 0; i < allListings.length; i++) {
87
- if (newFilteredListings[i].entityId != -1) {
88
- newFilteredListings[i].fields.travelTime = fetchedEntities[newFilteredListings[i].entityId].travelTime;
89
- }
90
- }
91
- for (var j = 0; j < newFilteredListings.length; j++) {
92
- if (newFilteredListings[j].entityId != -1) {
93
- newFilteredListings[j].fields.travelTime = fetchedEntities[newFilteredListings[j].entityId].travelTime;
94
- }
95
- }
96
- setNewFilteredListings(newFilteredListings);
97
- } catch (error) {
98
- console.error("Failed to fetch listing entities:", error);
99
- }
100
- }
101
-
102
- fetchEntities();
103
- }, [commuteLocation, allListings, siteConfig.companyId]);
104
-
105
- useEffect(() => {
106
- const handleFetchListings = async () => {
107
- if (!getStorageObject('listings', []).length > 0) {
108
- setLoading(true);
109
- }
110
-
111
- try {
112
- const {
113
- listingsResult,
114
- fetchedRecruiters,
115
- fetchedEntities,
116
- distinctItems
117
- } = await fetchListings(query, siteConfig, commuteLocation);
118
- setAllListings(listingsResult);
119
- setRecruiters(fetchedRecruiters);
120
- setListingEntities(fetchedEntities);
121
- setMapItems(distinctItems);
122
- setStorageObject("mapItems", distinctItems);
123
- setStorageObject("listingEntities", fetchedEntities);
124
- setStorageObject("recruiters", fetchedRecruiters);
125
- setStorageObject("listings", listingsResult);
126
- } catch (error) {
127
- console.log(error);
128
- }
129
- setLoading(false);
130
- };
131
- handleFetchListings();
132
- }, [query, siteConfig]);
133
-
134
- useEffect(() => {
135
- const processListings = () => {
136
- let { filteredListings, mapItems } = applyFilters(
137
- allListings,
138
- selectedFilters,
139
- query,
140
- listingEntities,
141
- favorites,
142
- siteConfig
143
- );
144
- if (filterByFavorites) {
145
- filteredListings = filteredListings.filter(x => favorites.includes(x.id));
146
- }
147
- setNewFilteredListings(filteredListings);
148
- // if (firstLoad && hasFiltersInURL(location)) {
149
- // const { filters } = filtersFromURL(location);
150
- // setSelectedFilters(filters);
151
- // }
152
- if (firstLoad && selectedFilters) {
153
- //updateURLWithFilters(selectedFilters,location, navigate, query);
154
- } else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
155
- localStorage.removeItem('selectedFilters');
156
- //updateURLWithFilters(selectedFilters,location, navigate, query);
157
- } else if (!firstLoad) {
158
- setStorageObject('selectedFilters', selectedFilters);
159
- //updateURLWithFilters(selectedFilters,location, navigate, query);
160
- }
161
- query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
162
- setMapItems(mapItems);
163
-
164
- if (selectedFilters) {
165
- const keys = Object.keys(selectedFilters);
166
- const lastKey = keys[keys.length - 1];
167
- const options = generateFilterOptions(
168
- firstLoad ? allListings : filteredListings,
169
- allListings,
170
- siteConfig,
171
- filterOptions,
172
- lastKey,
173
- favorites
174
- );
175
- if (options) {
176
- setFilterOptions(options);
177
- if (firstLoad) setFirstLoad(false);
178
- }
179
- }
180
- };
181
-
182
- processListings();
183
- }, [selectedFilters, query, listingEntities, filterByFavorites, favorites]);
184
-
185
- const handleFilterListingsByLocation = selectedLocation => {
186
- let { filteredListings } = filterListingsByLocation(
187
- allListings,
188
- selectedLocation,
189
- listingEntities
190
- );
191
-
192
- setNewFilteredListings(filteredListings);
193
- //setMapItems(mapItems);
194
- };
195
-
196
- const handleSettingFavorites = newFavorites => {
197
- if (newFavorites == null) {
198
- localStorage.removeItem('favorites');
199
- } else {
200
- setFavorites(newFavorites);
201
- localStorage.setItem('favorites', JSON.stringify(newFavorites));
202
- }
203
- };
204
-
205
- return (
206
- <MapListContext.Provider value={{
207
- loading,
208
- allListings,
209
- filteredListings,
210
- mapItems,
211
- query,
212
- setNewFilteredListings,
213
- setQuery,
214
- listingEntities,
215
- selectedFilters,
216
- setSelectedFilters,
217
- filterOptions,
218
- recruiters,
219
- handleFilterListingsByLocation,
220
- filterDialogIsOpen,
221
- setFilterDialogIsOpen,
222
- setMobileTab,
223
- mobileTab,
224
- siteConfig,
225
- favorites,
226
- handleSettingFavorites,
227
- setFilterByFavorites,
228
- filterByFavorites,
229
- commuteLocation,
230
- setCommuteLocation,
231
- navigateToDetails,
232
- navigateToEasyApply,
233
- Link,
234
- linkFormat,
235
- sortSetting,
236
- setSortSetting,
237
- trackEvent
238
- }}>
239
- {children}
240
- </MapListContext.Provider>
241
- );
242
- };
@@ -1,50 +0,0 @@
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 +0,0 @@
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,26 +0,0 @@
1
- import api from '~/apis/hcApi';
2
-
3
- export const getListings = async () => {
4
- try {
5
- const response = await api.get(`/Listings`);
6
- return response;
7
- } catch (error) {
8
- console.error(error);
9
- throw error;
10
- }
11
- };
12
-
13
- export const getListingDetails = async listingId => {
14
- try {
15
- const response = await api.get(`/ListingDetails/${listingId}`);
16
- return response;
17
- } catch (error) {
18
- console.error(error);
19
- throw error;
20
- }
21
- };
22
-
23
- export default {
24
- getListings,
25
- getListingDetails
26
- };
@@ -1,27 +0,0 @@
1
- export const getStorageObject = (item, defaultItem = null) =>{
2
- if(typeof window == 'undefined') return defaultItem;
3
- if(localStorage.getItem(item) == null) return defaultItem;
4
- if(localStorage.getItem(item) == 'undefined'){
5
- localStorage.removeItem(item);
6
- }
7
- return JSON.parse(localStorage.getItem(item)) ?? defaultItem;
8
- };
9
-
10
- export const getStorageItem = (item, defaultItem = null) =>{
11
- if(typeof window == 'undefined') return defaultItem;
12
- if(localStorage.getItem(item) == null) return defaultItem;
13
- if(localStorage.getItem(item) == 'undefined'){
14
- localStorage.removeItem(item);
15
- }
16
- return localStorage.getItem(item) ?? defaultItem;
17
- };
18
-
19
- export const setStorageObject = (key, item) =>{
20
- if(typeof window == 'undefined') return;
21
- if(item == undefined)return;
22
- try{
23
- localStorage.setItem(key, JSON.stringify(item));
24
- }catch(err){
25
- console.log(err);
26
- }
27
- };