@abcagency/hc-ui-components 1.3.15 → 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 (62) hide show
  1. package/dist/components/HireControlMap.js +15 -5
  2. package/dist/components/HireControlMap.js.map +1 -1
  3. package/dist/components/modules/accordions/MapAccordionItem.js +11 -1
  4. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  5. package/dist/components/modules/accordions/filterItem.js.map +1 -1
  6. package/dist/components/modules/accordions/filters.js.map +1 -1
  7. package/dist/components/modules/buttons/button-group-apply.js +36 -15
  8. package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
  9. package/dist/components/modules/filter/commute.js +22 -6
  10. package/dist/components/modules/filter/commute.js.map +1 -1
  11. package/dist/components/modules/filter/index.js +7 -0
  12. package/dist/components/modules/filter/index.js.map +1 -1
  13. package/dist/components/modules/filter/item.js +10 -0
  14. package/dist/components/modules/filter/item.js.map +1 -1
  15. package/dist/components/modules/filter/location.js +2 -4
  16. package/dist/components/modules/filter/location.js.map +1 -1
  17. package/dist/components/modules/filter/radio-item.js +7 -0
  18. package/dist/components/modules/filter/radio-item.js.map +1 -1
  19. package/dist/components/modules/jobListing/listing-details.js +6 -0
  20. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  21. package/dist/components/modules/maps/info-window-content.js +20 -0
  22. package/dist/components/modules/maps/info-window-content.js.map +1 -1
  23. package/dist/components/modules/maps/list/index.js +10 -2
  24. package/dist/components/modules/maps/list/index.js.map +1 -1
  25. package/dist/components/modules/maps/list/list-item/index.js +12 -2
  26. package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
  27. package/dist/components/modules/maps/map-marker.js +10 -0
  28. package/dist/components/modules/maps/map-marker.js.map +1 -1
  29. package/dist/constants/eventTypes.js +16 -0
  30. package/dist/constants/eventTypes.js.map +1 -0
  31. package/dist/contexts/mapContext.js.map +1 -1
  32. package/dist/contexts/mapListContext.js +4 -2
  33. package/dist/contexts/mapListContext.js.map +1 -1
  34. package/dist/contexts/trackEventContext.js +20 -0
  35. package/dist/contexts/trackEventContext.js.map +1 -0
  36. package/dist/hooks/useList.js.map +1 -1
  37. package/dist/services/listingAggregatorService.js.map +1 -1
  38. package/dist/util/mapIconUtil.js.map +1 -1
  39. package/package.json +60 -60
  40. package/src/components/HireControlMap.js +60 -55
  41. package/src/components/modules/accordions/MapAccordionItem.js +3 -1
  42. package/src/components/modules/accordions/filterItem.js +55 -55
  43. package/src/components/modules/accordions/filters.js +47 -47
  44. package/src/components/modules/buttons/button-group-apply.js +73 -66
  45. package/src/components/modules/filter/commute.js +7 -2
  46. package/src/components/modules/filter/index.js +89 -87
  47. package/src/components/modules/filter/item.js +87 -81
  48. package/src/components/modules/filter/location.js +71 -73
  49. package/src/components/modules/filter/radio-item.js +4 -0
  50. package/src/components/modules/jobListing/listing-details.js +4 -0
  51. package/src/components/modules/maps/info-window-content.js +8 -1
  52. package/src/components/modules/maps/list/index.js +112 -107
  53. package/src/components/modules/maps/list/list-item/index.js +3 -1
  54. package/src/components/modules/maps/map-marker.js +3 -1
  55. package/src/constants/eventTypes.js +13 -0
  56. package/src/contexts/mapContext.js +101 -101
  57. package/src/contexts/mapListContext.js +242 -240
  58. package/src/contexts/trackEventContext.js +14 -0
  59. package/src/hooks/useList.js +89 -89
  60. package/src/services/listingAggregatorService.js +50 -50
  61. package/src/util/mapIconUtil.js +18 -18
  62. package/src/util/urlFilterUtil.js +90 -90
@@ -1,240 +1,242 @@
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
- }) => {
33
- // const location = useLocation();
34
- // const navigate = useNavigate();
35
- const [allListings, setAllListings] = useState(getStorageObject("listings", []));
36
- const [filteredListings, setFilteredListings] = useState([]);
37
- const [loading, setLoading] = useState(false);
38
- const [mapItems, setMapItems] = useState(getStorageObject('mapItems', []));
39
- const [query, setQuery] = useState(() => resetFilters ? null : getQuery());
40
- const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
41
- const [listingEntities, setListingEntities] = useState(getStorageObject("listingEntities", null));
42
- const [firstLoad, setFirstLoad] = useState(true);
43
- const [commuteLocation, setCommuteLocation] = useState(getStorageObject('commuteLocation'));
44
- const [selectedFilters, setSelectedFilters] = useState(() => resetFilters ? {} : getStorageObject('selectedFilters', {}));//hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
45
- const [filterOptions, setFilterOptions] = useState();
46
- const [recruiters, setRecruiters] = useState(getStorageObject("recruiters", {}));
47
- const [filterDialogIsOpen, setFilterDialogIsOpen] = useState(false);
48
- const [mobileTab, setMobileTab] = useState("listTab");
49
- const [favorites, setFavorites] = useState([]);
50
- const [filterByFavorites, setFilterByFavorites] = useState(false);
51
-
52
- const setNewFilteredListings = filteredListings =>{
53
- setFilteredListings(filteredListings);
54
- };
55
-
56
- useEffect(() => {
57
- if (!sortSetting) return;
58
- localStorage.setItem('sortSetting', JSON.stringify(sortSetting));
59
- setNewFilteredListings(filteredListings);
60
- }, [sortSetting]);
61
-
62
- useEffect(() => {
63
- const loadedFavorites = JSON.parse(localStorage.getItem('favorites')) || [];
64
- setFavorites(loadedFavorites);
65
- }, []);
66
-
67
- useEffect(() => {
68
- setStorageObject("commuteLocation", commuteLocation);
69
- }, [commuteLocation]);
70
-
71
- useEffect(() => {
72
- if (commuteLocation === null || commuteLocation === '') return;
73
- async function fetchEntities() {
74
- const distinctEntityIds = [
75
- // eslint-disable-next-line no-undef
76
- ...new Set(allListings.map(listing => listing.entityId))
77
- ];
78
- try {
79
- const fetchedEntities = await getListingEntities(
80
- distinctEntityIds,
81
- `${commuteLocation.lat}, ${commuteLocation.lng}`
82
- );
83
- setListingEntities(fetchedEntities);
84
- var newFilteredListings = filteredListings;
85
- for (var i = 0; i < allListings.length; i++) {
86
- if (newFilteredListings[i].entityId != -1) {
87
- newFilteredListings[i].fields.travelTime = fetchedEntities[newFilteredListings[i].entityId].travelTime;
88
- }
89
- }
90
- for (var j = 0; j < newFilteredListings.length; j++) {
91
- if (newFilteredListings[j].entityId != -1) {
92
- newFilteredListings[j].fields.travelTime = fetchedEntities[newFilteredListings[j].entityId].travelTime;
93
- }
94
- }
95
- setNewFilteredListings(newFilteredListings);
96
- } catch (error) {
97
- console.error("Failed to fetch listing entities:", error);
98
- }
99
- }
100
-
101
- fetchEntities();
102
- }, [commuteLocation, allListings, siteConfig.companyId]);
103
-
104
- useEffect(() => {
105
- const handleFetchListings = async () => {
106
- if (!getStorageObject('listings', []).length > 0) {
107
- setLoading(true);
108
- }
109
-
110
- try {
111
- const {
112
- listingsResult,
113
- fetchedRecruiters,
114
- fetchedEntities,
115
- distinctItems
116
- } = await fetchListings(query, siteConfig, commuteLocation);
117
- setAllListings(listingsResult);
118
- setRecruiters(fetchedRecruiters);
119
- setListingEntities(fetchedEntities);
120
- setMapItems(distinctItems);
121
- setStorageObject("mapItems", distinctItems);
122
- setStorageObject("listingEntities", fetchedEntities);
123
- setStorageObject("recruiters", fetchedRecruiters);
124
- setStorageObject("listings", listingsResult);
125
- } catch (error) {
126
- console.log(error);
127
- }
128
- setLoading(false);
129
- };
130
- handleFetchListings();
131
- }, [query, siteConfig]);
132
-
133
- useEffect(() => {
134
- const processListings = () => {
135
- let { filteredListings, mapItems } = applyFilters(
136
- allListings,
137
- selectedFilters,
138
- query,
139
- listingEntities,
140
- favorites,
141
- siteConfig
142
- );
143
- if (filterByFavorites) {
144
- filteredListings = filteredListings.filter(x => favorites.includes(x.id));
145
- }
146
- setNewFilteredListings(filteredListings);
147
- // if (firstLoad && hasFiltersInURL(location)) {
148
- // const { filters } = filtersFromURL(location);
149
- // setSelectedFilters(filters);
150
- // }
151
- if (firstLoad && selectedFilters) {
152
- //updateURLWithFilters(selectedFilters,location, navigate, query);
153
- } else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
154
- localStorage.removeItem('selectedFilters');
155
- //updateURLWithFilters(selectedFilters,location, navigate, query);
156
- } else if (!firstLoad) {
157
- setStorageObject('selectedFilters', selectedFilters);
158
- //updateURLWithFilters(selectedFilters,location, navigate, query);
159
- }
160
- query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
161
- setMapItems(mapItems);
162
-
163
- if (selectedFilters) {
164
- const keys = Object.keys(selectedFilters);
165
- const lastKey = keys[keys.length - 1];
166
- const options = generateFilterOptions(
167
- firstLoad ? allListings : filteredListings,
168
- allListings,
169
- siteConfig,
170
- filterOptions,
171
- lastKey,
172
- favorites
173
- );
174
- if (options) {
175
- setFilterOptions(options);
176
- if (firstLoad) setFirstLoad(false);
177
- }
178
- }
179
- };
180
-
181
- processListings();
182
- }, [selectedFilters, query, listingEntities, filterByFavorites, favorites]);
183
-
184
- const handleFilterListingsByLocation = selectedLocation => {
185
- let { filteredListings } = filterListingsByLocation(
186
- allListings,
187
- selectedLocation,
188
- listingEntities
189
- );
190
-
191
- setNewFilteredListings(filteredListings);
192
- //setMapItems(mapItems);
193
- };
194
-
195
- const handleSettingFavorites = newFavorites => {
196
- if (newFavorites == null) {
197
- localStorage.removeItem('favorites');
198
- } else {
199
- setFavorites(newFavorites);
200
- localStorage.setItem('favorites', JSON.stringify(newFavorites));
201
- }
202
- };
203
-
204
- return (
205
- <MapListContext.Provider value={{
206
- loading,
207
- allListings,
208
- filteredListings,
209
- mapItems,
210
- query,
211
- setNewFilteredListings,
212
- setQuery,
213
- listingEntities,
214
- selectedFilters,
215
- setSelectedFilters,
216
- filterOptions,
217
- recruiters,
218
- handleFilterListingsByLocation,
219
- filterDialogIsOpen,
220
- setFilterDialogIsOpen,
221
- setMobileTab,
222
- mobileTab,
223
- siteConfig,
224
- favorites,
225
- handleSettingFavorites,
226
- setFilterByFavorites,
227
- filterByFavorites,
228
- commuteLocation,
229
- setCommuteLocation,
230
- navigateToDetails,
231
- navigateToEasyApply,
232
- Link,
233
- linkFormat,
234
- sortSetting,
235
- setSortSetting
236
- }}>
237
- {children}
238
- </MapListContext.Provider>
239
- );
240
- };
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
+ };
@@ -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
+ };