@abcagency/hc-ui-components 1.3.21 → 1.3.23

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 (149) hide show
  1. package/dist/components/containers/accordions/filter-container.js +4 -2
  2. package/dist/components/containers/accordions/filter-container.js.map +1 -1
  3. package/dist/components/containers/accordions/filter-item-container.js +6 -1
  4. package/dist/components/containers/accordions/filter-item-container.js.map +1 -1
  5. package/dist/components/containers/accordions/map-accordion-item-container.js +4 -2
  6. package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
  7. package/dist/components/containers/jobListing/listing-details-container.js +2 -2
  8. package/dist/components/containers/jobListing/listing-details-container.js.map +1 -1
  9. package/dist/components/containers/list/item-list-container.js +2 -2
  10. package/dist/components/containers/list/item-list-container.js.map +1 -1
  11. package/dist/components/modules/accordions/MapAccordionItem.js +2 -1
  12. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  13. package/dist/components/modules/dialogs/apply-dialog.js +1 -1
  14. package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
  15. package/dist/components/modules/filter/search.js +1 -1
  16. package/dist/components/modules/filter/search.js.map +1 -1
  17. package/dist/components/modules/jobListing/listing-details.js +5 -4
  18. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  19. package/dist/components/modules/list/field-mapper.js +1 -1
  20. package/dist/components/modules/list/field-mapper.js.map +1 -1
  21. package/dist/components/modules/list/item-list.js.map +1 -1
  22. package/dist/contexts/mapListContext.js.map +1 -1
  23. package/dist/services/listingAggregatorService.js.map +1 -1
  24. package/dist/styles/index.css +3 -1
  25. package/dist/types/components/containers/jobListing/listing-details-container.d.ts +2 -2
  26. package/dist/types/components/modules/accordions/MapAccordionItem.d.ts +2 -1
  27. package/dist/types/components/modules/jobListing/listing-details.d.ts +2 -2
  28. package/dist/types/components/modules/list/item-list.d.ts +0 -1
  29. package/dist/types/types/ListingFields.d.ts +5 -0
  30. package/dist/types/types/config/MapConfig.d.ts +1 -0
  31. package/dist/util/filterUtil.js +2 -2
  32. package/dist/util/filterUtil.js.map +1 -1
  33. package/package.json +4 -1
  34. package/.env +0 -3
  35. package/.eslintrc +0 -136
  36. package/bundle.js +0 -28134
  37. package/bundle.js.map +0 -1
  38. package/bundleDist.map +0 -1
  39. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +0 -12
  40. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  41. package/jsconfig.json +0 -7
  42. package/postcss.config.js +0 -13
  43. package/preset.default.js +0 -15
  44. package/rollup.config.mjs +0 -111
  45. package/src/.editorconfig +0 -12
  46. package/src/apis/hcApi.ts +0 -109
  47. package/src/bundleIndex.js +0 -14
  48. package/src/clientToken.js +0 -9
  49. package/src/components/HireControlMap.js +0 -135
  50. package/src/components/containers/accordions/filter-container.js +0 -47
  51. package/src/components/containers/accordions/filter-item-container.js +0 -62
  52. package/src/components/containers/accordions/map-accordion-item-container.js +0 -70
  53. package/src/components/containers/filter/commute-container.js +0 -89
  54. package/src/components/containers/filter/filter-container.js +0 -76
  55. package/src/components/containers/filter/filter-item-container.js +0 -71
  56. package/src/components/containers/filter/location-container.js +0 -45
  57. package/src/components/containers/filter/points-of-interest-container.js +0 -33
  58. package/src/components/containers/filter/points-of-interest-radio-item-container.js +0 -35
  59. package/src/components/containers/filter/search-container.js +0 -50
  60. package/src/components/containers/jobListing/listing-details-container.js +0 -40
  61. package/src/components/containers/list/item-list-container.tsx +0 -82
  62. package/src/components/containers/list/list-item/list-item-container.js +0 -43
  63. package/src/components/containers/maps/info-window-content-container.js +0 -51
  64. package/src/components/containers/maps/map-container.js +0 -204
  65. package/src/components/containers/maps/map-list-container.js +0 -48
  66. package/src/components/containers/maps/map-marker-container.js +0 -78
  67. package/src/components/modules/accordions/MapAccordionItem.js +0 -29
  68. package/src/components/modules/accordions/default.js +0 -171
  69. package/src/components/modules/accordions/filterItem.js +0 -27
  70. package/src/components/modules/accordions/filters.js +0 -32
  71. package/src/components/modules/buttons/button-group-apply.js +0 -123
  72. package/src/components/modules/buttons/commute-pill.js +0 -22
  73. package/src/components/modules/buttons/default.js +0 -194
  74. package/src/components/modules/buttons/items-pill.js +0 -35
  75. package/src/components/modules/buttons/pill-wrapper.js +0 -27
  76. package/src/components/modules/buttons/show-all-button.js +0 -20
  77. package/src/components/modules/cards/default.js +0 -167
  78. package/src/components/modules/cards/filter.js +0 -56
  79. package/src/components/modules/dialogs/apply-dialog.js +0 -48
  80. package/src/components/modules/filter/commute.js +0 -108
  81. package/src/components/modules/filter/index.js +0 -55
  82. package/src/components/modules/filter/item.js +0 -48
  83. package/src/components/modules/filter/location.js +0 -48
  84. package/src/components/modules/filter/radio-item.js +0 -42
  85. package/src/components/modules/filter/search.js +0 -65
  86. package/src/components/modules/filter/sort.js +0 -83
  87. package/src/components/modules/grid.js +0 -54
  88. package/src/components/modules/icon.js +0 -33
  89. package/src/components/modules/jobListing/listing-details.js +0 -109
  90. package/src/components/modules/list/field-mapper.js +0 -114
  91. package/src/components/modules/list/header-item.js +0 -91
  92. package/src/components/modules/list/header.js +0 -49
  93. package/src/components/modules/list/item-expand-card/index.js +0 -22
  94. package/src/components/modules/list/item-expand-card/recruiter-contact-nav.js +0 -50
  95. package/src/components/modules/list/item-expand-card/recruiter-details.js +0 -68
  96. package/src/components/modules/list/item-expand-card/recruiter-headshot.js +0 -22
  97. package/src/components/modules/list/item-list.tsx +0 -85
  98. package/src/components/modules/list/list-item/list-item.js +0 -130
  99. package/src/components/modules/maps/info-window-card.js +0 -17
  100. package/src/components/modules/maps/info-window-content.js +0 -35
  101. package/src/components/modules/maps/map-list.js +0 -28
  102. package/src/components/modules/maps/map-marker.js +0 -29
  103. package/src/components/modules/maps/map.js +0 -76
  104. package/src/components/modules/maps/place-marker.js +0 -41
  105. package/src/components/modules/maps/tabs.js +0 -81
  106. package/src/constants/eventTypes.js +0 -13
  107. package/src/constants/placeTypes.js +0 -8
  108. package/src/contexts/mapContext.tsx +0 -129
  109. package/src/contexts/mapListContext.tsx +0 -311
  110. package/src/contexts/placesContext.js +0 -102
  111. package/src/contexts/trackEventContext.js +0 -14
  112. package/src/enums/SectionType.ts +0 -9
  113. package/src/hooks/useList.js +0 -89
  114. package/src/index.js +0 -3
  115. package/src/services/configService.ts +0 -16
  116. package/src/services/googlePlacesNearbyService.ts +0 -42
  117. package/src/services/listingAggregatorService.ts +0 -76
  118. package/src/services/listingEntityService.ts +0 -16
  119. package/src/services/listingService.ts +0 -40
  120. package/src/services/recruiterService.ts +0 -18
  121. package/src/styles/bundle.css +0 -268
  122. package/src/styles/index.css +0 -125
  123. package/src/types/Address.ts +0 -7
  124. package/src/types/ContentSection.ts +0 -9
  125. package/src/types/GetListingParams.ts +0 -8
  126. package/src/types/LatLng.ts +0 -4
  127. package/src/types/ListingEntity.ts +0 -11
  128. package/src/types/ListingFields.ts +0 -20
  129. package/src/types/Listings.ts +0 -32
  130. package/src/types/Recruiter.ts +0 -9
  131. package/src/types/SimilarListing.ts +0 -24
  132. package/src/types/config/Colors.ts +0 -8
  133. package/src/types/config/MapConfig.ts +0 -30
  134. package/src/types/config/PointsOfInterestConfig.ts +0 -13
  135. package/src/types/config/SearchConfig.ts +0 -4
  136. package/src/util/arrayUtil.js +0 -3
  137. package/src/util/fieldMapper.js +0 -22
  138. package/src/util/filterUtil.js +0 -239
  139. package/src/util/loading.js +0 -17
  140. package/src/util/localStorageUtil.ts +0 -34
  141. package/src/util/mapIconUtil.js +0 -180
  142. package/src/util/mapUtil.js +0 -91
  143. package/src/util/sortUtil.js +0 -33
  144. package/src/util/stringUtils.js +0 -6
  145. package/src/util/urlFilterUtil.js +0 -85
  146. package/stats.html +0 -4842
  147. package/styles/index.css +0 -1
  148. package/tailwind.config.js +0 -129
  149. package/tsconfig.json +0 -23
@@ -1,311 +0,0 @@
1
- import React, { createContext, useState, useEffect, useContext, ReactNode } from 'react';
2
-
3
- import { generateFilterOptions, applyFilters, filterListingsByLocation } from '~/util/filterUtil';
4
- import { getStorageObject, setStorageObject } from '~/util/localStorageUtil';
5
- import { updateURLWithFilters, filtersFromURL } from '~/util/urlFilterUtil';
6
-
7
- import { getListingEntities } from "~/services/listingEntityService";
8
- import fetchListings from '~/services/listingAggregatorService';
9
-
10
- import { Listing } from '~/types/Listings';
11
- import { ListingEntity } from '~/types/ListingEntity';
12
- import { Recruiter } from '~/types/Recruiter';
13
- import { MapConfig, MapConfig as SiteConfig } from '~/types/config/MapConfig';
14
-
15
- interface MapListContextProps {
16
- loading: boolean;
17
- allListings: Listing[];
18
- filteredListings: Listing[];
19
- mapItems: any;
20
- query: string | null;
21
- setNewFilteredListings: (filteredListings: Listing[]) => void;
22
- setQuery: (query: string | null) => void;
23
- listingEntities: Record<number, ListingEntity> | null;
24
- selectedFilters: Record<string, any>;
25
- setSelectedFilters: (filters: Record<string, any>) => void;
26
- filterOptions: any;
27
- recruiters: Record<number, Recruiter>;
28
- handleFilterListingsByLocation: (selectedLocation: any) => void;
29
- filterDialogIsOpen: boolean;
30
- setFilterDialogIsOpen: (isOpen: boolean) => void;
31
- setMobileTab: (tab: string) => void;
32
- mobileTab: string;
33
- siteConfig: SiteConfig;
34
- favorites: number[];
35
- handleSettingFavorites: (favorites: number[] | null) => void;
36
- setFilterByFavorites: (filter: boolean) => void;
37
- filterByFavorites: boolean;
38
- commuteLocation: any | null;
39
- setCommuteLocation: (location: any | null) => void;
40
- navigateToDetails: (id: number) => void;
41
- navigateToEasyApply: (id: number) => void;
42
- Link: React.ComponentType<any>;
43
- linkFormat: string;
44
- sortSetting: { field: string; type: string };
45
- setSortSetting: (setting: { field: string; type: string }) => void;
46
- trackEvent: (event: string) => void;
47
- }
48
-
49
- const MapListContext = createContext<MapListContextProps | undefined>(undefined);
50
-
51
- export const useMapList = () => {
52
- const context = useContext(MapListContext);
53
- if (!context) {
54
- throw new Error('useMapList must be used within a MapListProvider');
55
- }
56
- return context;
57
- };
58
-
59
- const getQuery = (): string | null => {
60
- let query: string | null = null;
61
- if (typeof window !== 'undefined') {
62
- query = localStorage.getItem('query');
63
- }
64
- return query;
65
- };
66
-
67
- interface MapListProviderProps {
68
- children: ReactNode;
69
- siteConfig: MapConfig;
70
- resetFilters: boolean;
71
- navigateToDetails: (id: number) => void;
72
- navigateToEasyApply: (id: number) => void;
73
- Link: React.ComponentType<any>;
74
- linkFormat: string;
75
- trackEvent: (event: string) => void;
76
- listings?: Listing[];
77
- setFiltersUrl?:boolean;
78
- }
79
-
80
- export const MapListProvider: React.FC<MapListProviderProps> = ({
81
- children,
82
- siteConfig,
83
- resetFilters,
84
- navigateToDetails,
85
- navigateToEasyApply,
86
- Link,
87
- linkFormat,
88
- trackEvent,
89
- listings = [],
90
- setFiltersUrl
91
- }) => {
92
- const firstLoadFilters = () =>{
93
- let urlFilters = filtersFromURL(window.location)?.filters;
94
- return (setFiltersUrl === true && urlFilters && Object.keys(urlFilters).length > 0) ? urlFilters : getStorageObject('selectedFilters', {}) || {}
95
- }
96
- const [allListings, setAllListings] = useState<Listing[]>(getStorageObject("listings", listings) || []);
97
- const [filteredListings, setFilteredListings] = useState<Listing[]>([]);
98
- const [loading, setLoading] = useState<boolean>(false);
99
- const [mapItems, setMapItems] = useState<any>(getStorageObject('mapItems', []) || []);
100
- const [query, setQuery] = useState<string | null>(() => resetFilters ? null : getQuery());
101
- const [sortSetting, setSortSetting] = useState<{ field: string; type: string }>(getStorageObject('sortSetting', { field: 'position', type: 'asc' }) || { field: 'position', type: 'asc' });
102
- const [listingEntities, setListingEntities] = useState<Record<number, ListingEntity> | null>(getStorageObject("listingEntities", null));
103
- const [firstLoad, setFirstLoad] = useState<boolean>(true);
104
- const [commuteLocation, setCommuteLocation] = useState<any | null>(getStorageObject('commuteLocation'));
105
- const [selectedFilters, setSelectedFilters] = useState<Record<string, any>>(() => resetFilters ? {} : firstLoadFilters());
106
- const [filterOptions, setFilterOptions] = useState<any>();
107
- const [recruiters, setRecruiters] = useState<Record<number, Recruiter>>(getStorageObject("recruiters", {}) || {});
108
- const [filterDialogIsOpen, setFilterDialogIsOpen] = useState<boolean>(false);
109
- const [mobileTab, setMobileTab] = useState<string>("listTab");
110
- const [favorites, setFavorites] = useState<number[]>([]);
111
- const [filterByFavorites, setFilterByFavorites] = useState<boolean>(false);
112
-
113
- const setNewFilteredListings = (filteredListings: Listing[]) => {
114
- setFilteredListings(filteredListings);
115
- };
116
-
117
-
118
-
119
- useEffect(() => {
120
- if (!sortSetting) return;
121
- localStorage.setItem('sortSetting', JSON.stringify(sortSetting));
122
- setNewFilteredListings(filteredListings);
123
- }, [sortSetting]);
124
-
125
- useEffect(() => {
126
- const loadedFavorites = JSON.parse(localStorage.getItem('favorites') || '[]');
127
- setFavorites(loadedFavorites);
128
- }, []);
129
-
130
- useEffect(() => {
131
- setStorageObject("commuteLocation", commuteLocation);
132
- }, [commuteLocation]);
133
-
134
- useEffect(() => {
135
- if (!commuteLocation) return;
136
-
137
- async function fetchEntities() {
138
- const distinctEntityIds = [
139
- ...new Set(allListings.map(listing => listing.entityId ?? -1))
140
- ];
141
- try {
142
- const fetchedEntities = await getListingEntities(
143
- distinctEntityIds,
144
- `${commuteLocation.lat}, ${commuteLocation.lng}`
145
- );
146
- setListingEntities(fetchedEntities);
147
- const newFilteredListings: Listing[] = [...filteredListings] ?? [];
148
- for (let i = 0; i < allListings.length; i++) {
149
- const listing = newFilteredListings[i];
150
- if (
151
- listing &&
152
- listing.fields &&
153
- listing.entityId !== undefined &&
154
- listing.entityId !== -1
155
- ) {
156
- const entityId = listing.entityId;
157
- const travelTime = fetchedEntities[entityId]?.travelTime;
158
-
159
- if (travelTime !== undefined && listing.fields) {
160
- listing.fields.travelTime = travelTime;
161
- }
162
- }
163
- }
164
- } catch (error) {
165
- console.error("Failed to fetch listing entities:", error);
166
- }
167
- }
168
-
169
- fetchEntities();
170
- }, [commuteLocation, allListings, siteConfig.companyId]);
171
-
172
- useEffect(() => {
173
- const handleFetchListings = async () => {
174
- if (!getStorageObject('listings') ?? [].length) {
175
- setLoading(true);
176
- }
177
-
178
- try {
179
- const {
180
- listingsResult,
181
- fetchedRecruiters,
182
- fetchedEntities,
183
- distinctItems
184
- } = await fetchListings(query ?? '', siteConfig, commuteLocation);
185
- setAllListings(listingsResult);
186
- setRecruiters(fetchedRecruiters);
187
- setListingEntities(fetchedEntities);
188
- setMapItems(distinctItems);
189
- setStorageObject("mapItems", distinctItems);
190
- setStorageObject("listingEntities", fetchedEntities);
191
- setStorageObject("recruiters", fetchedRecruiters);
192
- setStorageObject("listings", listingsResult);
193
- } catch (error) {
194
- console.log(error);
195
- }
196
- setLoading(false);
197
- };
198
- handleFetchListings();
199
- }, [query, siteConfig]);
200
-
201
- useEffect(() => {
202
- const processListings = () => {
203
- let filteredListings: Listing[];
204
- let tempSelectedFilters = selectedFilters;
205
- let tempQuery = query;
206
-
207
- const { mapItems, filteredListings: tempFilteredListings } = applyFilters(
208
- allListings,
209
- tempSelectedFilters,
210
- tempQuery,
211
- listingEntities,
212
- favorites,
213
- siteConfig
214
- );
215
- filteredListings = tempFilteredListings;
216
-
217
- if (filterByFavorites) {
218
- filteredListings = filteredListings.filter((x: Listing) => favorites.includes(x.id));
219
- }
220
- setNewFilteredListings(filteredListings);
221
- if (firstLoad && tempSelectedFilters) {
222
- // Update URL with filters if needed
223
- } else if (Object.keys(tempSelectedFilters).length === 0 && !firstLoad) {
224
- localStorage.removeItem('selectedFilters');
225
- } else if (!firstLoad) {
226
- setStorageObject('selectedFilters', tempSelectedFilters);
227
- }
228
- if(setFiltersUrl === true)
229
- {
230
- updateURLWithFilters(tempSelectedFilters, window.location, tempQuery);
231
- }
232
- tempQuery != null ? localStorage.setItem('query', tempQuery) : localStorage.removeItem('query');
233
- setMapItems(mapItems);
234
-
235
- if (tempSelectedFilters) {
236
- const keys = Object.keys(tempSelectedFilters);
237
- const lastKey = keys[keys.length - 1];
238
- const options = generateFilterOptions(
239
- firstLoad ? allListings : filteredListings,
240
- allListings,
241
- siteConfig,
242
- filterOptions,
243
- lastKey,
244
- favorites
245
- );
246
- if (options) {
247
- setFilterOptions(options);
248
- if (firstLoad) setFirstLoad(false);
249
- }
250
- }
251
- };
252
-
253
- processListings();
254
- }, [selectedFilters, query, listingEntities, filterByFavorites, favorites]);
255
-
256
- const handleFilterListingsByLocation = (selectedLocation: any) => {
257
- const { filteredListings } = filterListingsByLocation(
258
- allListings,
259
- selectedLocation,
260
- listingEntities
261
- );
262
- setNewFilteredListings(filteredListings);
263
- };
264
-
265
- const handleSettingFavorites = (newFavorites: number[] | null) => {
266
- if (newFavorites == null) {
267
- localStorage.removeItem('favorites');
268
- } else {
269
- setFavorites(newFavorites);
270
- localStorage.setItem('favorites', JSON.stringify(newFavorites));
271
- }
272
- };
273
-
274
- return (
275
- <MapListContext.Provider value={{
276
- loading,
277
- allListings,
278
- filteredListings,
279
- mapItems,
280
- query,
281
- setNewFilteredListings,
282
- setQuery,
283
- listingEntities,
284
- selectedFilters,
285
- setSelectedFilters,
286
- filterOptions,
287
- recruiters,
288
- handleFilterListingsByLocation,
289
- filterDialogIsOpen,
290
- setFilterDialogIsOpen,
291
- setMobileTab,
292
- mobileTab,
293
- siteConfig,
294
- favorites,
295
- handleSettingFavorites,
296
- setFilterByFavorites,
297
- filterByFavorites,
298
- commuteLocation,
299
- setCommuteLocation,
300
- navigateToDetails,
301
- navigateToEasyApply,
302
- Link,
303
- linkFormat,
304
- sortSetting,
305
- setSortSetting,
306
- trackEvent
307
- }}>
308
- {children}
309
- </MapListContext.Provider>
310
- );
311
- };
@@ -1,102 +0,0 @@
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,14 +0,0 @@
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,9 +0,0 @@
1
- export enum SectionType {
2
- Default = -1,
3
- Company = 1,
4
- Category = 2,
5
- CategoryClass = 3,
6
- Entity = 4,
7
- CustomVar = 5,
8
- REGION = 7
9
- }
@@ -1,89 +0,0 @@
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 DELETED
@@ -1,3 +0,0 @@
1
- import HireControlMap from '~/components/HireControlMap';
2
-
3
- export { HireControlMap };
@@ -1,16 +0,0 @@
1
- import api from '~/apis/hcApi';
2
- import { MapConfig } from '~/types/config/MapConfig';
3
-
4
- export const getMapConfig = async (): Promise<MapConfig> => {
5
- try {
6
- const response = await api.get<MapConfig>(`/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,42 +0,0 @@
1
- export interface Location {
2
- latitude: number;
3
- longitude: number;
4
- }
5
-
6
- export const searchNearbyPlaces = async (
7
- typesArray: string[],
8
- location: Location,
9
- radius: number
10
- ): Promise<any> => {
11
- const url = 'https://places.googleapis.com/v1/places:searchNearby';
12
- const headers = {
13
- 'Content-Type': 'application/json',
14
- 'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY as string,
15
- 'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
16
- };
17
- const data = {
18
- includedTypes: typesArray,
19
- maxResultCount: 20,
20
- locationRestriction: {
21
- circle: {
22
- center: location,
23
- radius: radius
24
- }
25
- }
26
- };
27
-
28
- try {
29
- const response = await fetch(url, {
30
- method: 'POST',
31
- headers: headers,
32
- body: JSON.stringify(data)
33
- });
34
- if (!response.ok) {
35
- throw new Error(`HTTP error! status: ${response.status}`);
36
- }
37
- return await response.json();
38
- } catch (error) {
39
- console.error('Error making the Nearby Search request:', error);
40
- throw error;
41
- }
42
- };
@@ -1,76 +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
- import { Listing } from '~/types/Listings';
7
- import { Recruiter } from '~/types/Recruiter';
8
- import { ListingEntity } from '~/types/ListingEntity';
9
- import { MapConfig } from '~/types/config/MapConfig';
10
- //import { ICommuteLocation } from '~/interfaces/ICommute';
11
-
12
- interface SiteConfig {
13
- companyId: number;
14
- }
15
-
16
- interface FetchListingsResult {
17
- listingsResult: Listing[];
18
- fetchedRecruiters: Recruiter[];
19
- fetchedEntities: Record<number, ListingEntity>;
20
- distinctItems: any; // Update this type based on the return type of getDistinctItemsByProximity
21
- }
22
-
23
- const fetchListings = async (
24
- query: string,
25
- siteConfig: MapConfig,
26
- commuteLocation: any | null = null
27
- ): Promise<FetchListingsResult> => {
28
- try {
29
- const listingsResult = await getListings(
30
-
31
- );
32
-
33
- const recruiterIds: number[] = [
34
- ...new Set(listingsResult.map(listing => listing.recruiterId))
35
- ] as number[];
36
-
37
- const fetchedRecruiters = await getRecruiters(recruiterIds);
38
-
39
- const distinctEntityIds: number[] = [
40
- ...new Set(listingsResult.map(listing => listing.entityId))
41
- ] as number[];
42
-
43
- const fetchedEntities = !commuteLocation
44
- ? await getListingEntities(distinctEntityIds)
45
- : await getListingEntities(
46
- distinctEntityIds,
47
- `${commuteLocation.lat}, ${commuteLocation.lng}`
48
- );
49
- for (let i = 0; i < listingsResult.length; i++) {
50
- const listing = listingsResult[i];
51
- if (listing.entityId && listing.entityId !== -1 && listing.fields) {
52
- const entity = fetchedEntities[listing.entityId];
53
- if (entity) {
54
- listing.fields.travelTime = entity.travelTime;
55
- }
56
- }
57
- }
58
-
59
- const distinctItems = getDistinctItemsByProximity(
60
- listingsResult,
61
- fetchedEntities
62
- );
63
-
64
- return {
65
- listingsResult,
66
- fetchedRecruiters,
67
- fetchedEntities,
68
- distinctItems
69
- };
70
- } catch (error) {
71
- console.error("Error fetching listings:", error);
72
- throw error;
73
- }
74
- };
75
-
76
- export default fetchListings;
@@ -1,16 +0,0 @@
1
- import api from '~/apis/hcApi';
2
- import { ListingEntity } from '~/types/ListingEntity';
3
-
4
- export const getListingEntities = async (entityIds: number[], origin = ''): Promise<ListingEntity[]> => {
5
- try {
6
- const response = await api.post<ListingEntity[]>(`/ListingEntities?origin=${origin}`, entityIds);
7
- return response;
8
- } catch (error) {
9
- console.error("Error fetching listing entities:", error);
10
- throw error;
11
- }
12
- };
13
-
14
- export default {
15
- getListingEntities
16
- };