@abcagency/hc-ui-components 1.3.13 → 1.3.15

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 (147) 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.map +1 -1
  6. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  7. package/dist/components/modules/accordions/default.js.map +1 -1
  8. package/dist/components/modules/accordions/filterItem.js +2 -1
  9. package/dist/components/modules/accordions/filterItem.js.map +1 -1
  10. package/dist/components/modules/accordions/filters.js +0 -3
  11. package/dist/components/modules/accordions/filters.js.map +1 -1
  12. package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
  13. package/dist/components/modules/buttons/commute-pill.js.map +1 -1
  14. package/dist/components/modules/buttons/default.js.map +1 -1
  15. package/dist/components/modules/buttons/items-pill.js.map +1 -1
  16. package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
  17. package/dist/components/modules/buttons/show-all-button.js.map +1 -1
  18. package/dist/components/modules/cards/default.js.map +1 -1
  19. package/dist/components/modules/cards/filter.js.map +1 -1
  20. package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
  21. package/dist/components/modules/filter/commute.js.map +1 -1
  22. package/dist/components/modules/filter/item.js +6 -1
  23. package/dist/components/modules/filter/item.js.map +1 -1
  24. package/dist/components/modules/filter/location.js +5 -3
  25. package/dist/components/modules/filter/location.js.map +1 -1
  26. package/dist/components/modules/filter/points-of-interest.js.map +1 -1
  27. package/dist/components/modules/filter/radio-item.js.map +1 -1
  28. package/dist/components/modules/filter/search.js.map +1 -1
  29. package/dist/components/modules/filter/sort.js.map +1 -1
  30. package/dist/components/modules/grid.js.map +1 -1
  31. package/dist/components/modules/icon.js.map +1 -1
  32. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  33. package/dist/components/modules/maps/info-window-card.js.map +1 -1
  34. package/dist/components/modules/maps/info-window-content.js.map +1 -1
  35. package/dist/components/modules/maps/list/field-mapper.js.map +1 -1
  36. package/dist/components/modules/maps/list/header-item.js.map +1 -1
  37. package/dist/components/modules/maps/list/header.js.map +1 -1
  38. package/dist/components/modules/maps/list/index.js +11 -10
  39. package/dist/components/modules/maps/list/index.js.map +1 -1
  40. package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
  41. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
  42. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
  43. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
  44. package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
  45. package/dist/components/modules/maps/map-list.js.map +1 -1
  46. package/dist/components/modules/maps/map-marker.js.map +1 -1
  47. package/dist/components/modules/maps/map.js.map +1 -1
  48. package/dist/components/modules/maps/place-marker.js.map +1 -1
  49. package/dist/components/modules/maps/tabs.js.map +1 -1
  50. package/dist/constants/placeTypes.js.map +1 -1
  51. package/dist/contexts/mapContext.js +9 -27
  52. package/dist/contexts/mapContext.js.map +1 -1
  53. package/dist/contexts/mapListContext.js +54 -37
  54. package/dist/contexts/mapListContext.js.map +1 -1
  55. package/dist/contexts/placesContext.js.map +1 -1
  56. package/dist/hooks/useList.js +3 -15
  57. package/dist/hooks/useList.js.map +1 -1
  58. package/dist/services/apis/hcApi.js +1 -1
  59. package/dist/services/apis/hcApi.js.map +1 -1
  60. package/dist/services/clientToken.js.map +1 -1
  61. package/dist/services/configService.js.map +1 -1
  62. package/dist/services/googlePlacesNearbyService.js.map +1 -1
  63. package/dist/services/listingAggregatorService.js +43 -16
  64. package/dist/services/listingAggregatorService.js.map +1 -1
  65. package/dist/services/listingEntityService.js.map +1 -1
  66. package/dist/services/listingService.js.map +1 -1
  67. package/dist/services/recruiterService.js.map +1 -1
  68. package/dist/util/filterUtil.js.map +1 -1
  69. package/dist/util/loading.js.map +1 -1
  70. package/dist/util/localStorageUtil.js.map +1 -1
  71. package/dist/util/mapIconUtil.js.map +1 -1
  72. package/dist/util/mapUtil.js.map +1 -1
  73. package/dist/util/sortUtil.js.map +1 -1
  74. package/dist/util/stringUtils.js.map +1 -1
  75. package/jsconfig.json +7 -7
  76. package/package.json +7 -7
  77. package/postcss.config.js +13 -13
  78. package/preset.default.js +15 -15
  79. package/rollup.config.mjs +88 -87
  80. package/src/apis/hcApi.js +93 -93
  81. package/src/clientToken.js +9 -9
  82. package/src/components/HireControlMap.js +124 -124
  83. package/src/components/modules/accordions/MapAccordionItem.js +72 -72
  84. package/src/components/modules/accordions/default.js +171 -171
  85. package/src/components/modules/accordions/filterItem.js +3 -1
  86. package/src/components/modules/accordions/filters.js +1 -1
  87. package/src/components/modules/buttons/button-group-apply.js +116 -116
  88. package/src/components/modules/buttons/commute-pill.js +22 -22
  89. package/src/components/modules/buttons/default.js +194 -194
  90. package/src/components/modules/buttons/items-pill.js +35 -35
  91. package/src/components/modules/buttons/pill-wrapper.js +27 -27
  92. package/src/components/modules/buttons/show-all-button.js +20 -20
  93. package/src/components/modules/cards/default.js +167 -167
  94. package/src/components/modules/cards/filter.js +56 -56
  95. package/src/components/modules/dialogs/apply-dialog.js +48 -48
  96. package/src/components/modules/filter/commute.js +149 -149
  97. package/src/components/modules/filter/item.js +5 -0
  98. package/src/components/modules/filter/location.js +5 -3
  99. package/src/components/modules/filter/points-of-interest.js +44 -44
  100. package/src/components/modules/filter/radio-item.js +53 -53
  101. package/src/components/modules/filter/search.js +92 -92
  102. package/src/components/modules/filter/sort.js +83 -83
  103. package/src/components/modules/grid.js +54 -54
  104. package/src/components/modules/icon.js +33 -33
  105. package/src/components/modules/jobListing/listing-details.js +95 -95
  106. package/src/components/modules/maps/info-window-card.js +17 -17
  107. package/src/components/modules/maps/info-window-content.js +74 -74
  108. package/src/components/modules/maps/list/field-mapper.js +112 -112
  109. package/src/components/modules/maps/list/header-item.js +91 -91
  110. package/src/components/modules/maps/list/header.js +47 -47
  111. package/src/components/modules/maps/list/index.js +7 -7
  112. package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
  113. package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
  114. package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
  115. package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
  116. package/src/components/modules/maps/list/list-item/index.js +133 -133
  117. package/src/components/modules/maps/map-list.js +74 -74
  118. package/src/components/modules/maps/map-marker.js +86 -86
  119. package/src/components/modules/maps/map.js +230 -230
  120. package/src/components/modules/maps/place-marker.js +41 -41
  121. package/src/components/modules/maps/tabs.js +81 -81
  122. package/src/constants/placeTypes.js +8 -8
  123. package/src/contexts/mapContext.js +0 -14
  124. package/src/contexts/mapListContext.js +26 -8
  125. package/src/contexts/placesContext.js +102 -102
  126. package/src/hooks/useList.js +4 -16
  127. package/src/index.js +3 -3
  128. package/src/services/configService.js +16 -16
  129. package/src/services/googlePlacesNearbyService.js +33 -33
  130. package/src/services/listingAggregatorService.js +9 -4
  131. package/src/services/listingEntityService.js +15 -15
  132. package/src/services/listingService.js +26 -26
  133. package/src/services/recruiterService.js +17 -17
  134. package/src/styles/index.css +23 -23
  135. package/src/util/arrayUtil.js +3 -3
  136. package/src/util/fieldMapper.js +22 -22
  137. package/src/util/filterUtil.js +195 -195
  138. package/src/util/loading.js +17 -17
  139. package/src/util/localStorageUtil.js +26 -26
  140. package/src/util/mapIconUtil.js +180 -180
  141. package/src/util/mapUtil.js +91 -91
  142. package/src/util/sortUtil.js +32 -32
  143. package/src/util/stringUtils.js +6 -6
  144. package/tailwind.config.js +126 -126
  145. package/.editorconfig +0 -12
  146. package/.eslintrc +0 -105
  147. package/.prettierignore +0 -3
@@ -1,81 +1,81 @@
1
- import React from 'react';
2
- import * as Tabs from '@radix-ui/react-tabs';
3
-
4
- import Button from '~/components/modules/buttons/default';
5
-
6
- import { useMapList } from '~/contexts/mapListContext';
7
-
8
- const MapTabs = ({
9
- map,
10
- list,
11
- filter,
12
- className,
13
- showMap
14
- }) => {
15
- const tabButtonClasses =
16
- "hc-flex hc-items-center hc-gap-2 hc-rounded-none hc-border-x-0 data-[state=active]:hc-bg-primary data-[state=active]:hc-text-white";
17
- const { mobileTab, setMobileTab } = useMapList();
18
- return (
19
- <div
20
- className={`
21
- hc-relative hc-overflow-hidden
22
- ${className ?? ""}
23
- `}
24
- >
25
- <Tabs.Root
26
- className="hc-flex hc-flex-col hc-h-screen hc-min-h-screen"
27
- //defaultValue="listTab"
28
- value={mobileTab}
29
- >
30
- <Tabs.List
31
- className="hc-w-full hc-shrink-0 hc-flex hc-divide-x hc-divide-primary"
32
- aria-label="Review positions"
33
- >
34
- <Tabs.Trigger value="listTab" asChild onClick={() => setMobileTab("listTab")}>
35
- <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
36
- <Button.Body className="hc-justify-center">
37
- <Button.Icon icon="mdi:view-list" size="hc-size-5" />
38
- List
39
- </Button.Body>
40
- </Button.Btn>
41
- </Tabs.Trigger>
42
- {showMap && (
43
- <Tabs.Trigger value="mapTab" asChild onClick={() => setMobileTab("mapTab")}>
44
- <Button.Btn
45
- variant="outline"
46
- isBlock
47
- className={tabButtonClasses}
48
- >
49
- <Button.Body className="hc-justify-center">
50
- <Button.Icon icon="mdi:map" size="hc-size-5" />
51
- Map
52
- </Button.Body>
53
- </Button.Btn>
54
- </Tabs.Trigger>
55
- )}
56
- <Tabs.Trigger value="filterTab" asChild onClick={() => setMobileTab("filterTab")}>
57
- <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
58
- <Button.Body className="hc-justify-center">
59
- <Button.Icon icon="fluent:search-12-filled" size="hc-size-5" />
60
- Filter
61
- </Button.Body>
62
- </Button.Btn>
63
- </Tabs.Trigger>
64
- </Tabs.List>
65
- <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="listTab">
66
- {list}
67
- </Tabs.Content>
68
- {showMap && (
69
- <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="mapTab">
70
- {map}
71
- </Tabs.Content>
72
- )}
73
- <Tabs.Content className="hc-grow hc-bg-white hc-outline-none hc-p-2" value="filterTab">
74
- {filter}
75
- </Tabs.Content>
76
- </Tabs.Root>
77
- </div>
78
- );
79
- };
80
-
81
- export default MapTabs;
1
+ import React from 'react';
2
+ import * as Tabs from '@radix-ui/react-tabs';
3
+
4
+ import Button from '~/components/modules/buttons/default';
5
+
6
+ import { useMapList } from '~/contexts/mapListContext';
7
+
8
+ const MapTabs = ({
9
+ map,
10
+ list,
11
+ filter,
12
+ className,
13
+ showMap
14
+ }) => {
15
+ const tabButtonClasses =
16
+ "hc-flex hc-items-center hc-gap-2 hc-rounded-none hc-border-x-0 data-[state=active]:hc-bg-primary data-[state=active]:hc-text-white";
17
+ const { mobileTab, setMobileTab } = useMapList();
18
+ return (
19
+ <div
20
+ className={`
21
+ hc-relative hc-overflow-hidden
22
+ ${className ?? ""}
23
+ `}
24
+ >
25
+ <Tabs.Root
26
+ className="hc-flex hc-flex-col hc-h-screen hc-min-h-screen"
27
+ //defaultValue="listTab"
28
+ value={mobileTab}
29
+ >
30
+ <Tabs.List
31
+ className="hc-w-full hc-shrink-0 hc-flex hc-divide-x hc-divide-primary"
32
+ aria-label="Review positions"
33
+ >
34
+ <Tabs.Trigger value="listTab" asChild onClick={() => setMobileTab("listTab")}>
35
+ <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
36
+ <Button.Body className="hc-justify-center">
37
+ <Button.Icon icon="mdi:view-list" size="hc-size-5" />
38
+ List
39
+ </Button.Body>
40
+ </Button.Btn>
41
+ </Tabs.Trigger>
42
+ {showMap && (
43
+ <Tabs.Trigger value="mapTab" asChild onClick={() => setMobileTab("mapTab")}>
44
+ <Button.Btn
45
+ variant="outline"
46
+ isBlock
47
+ className={tabButtonClasses}
48
+ >
49
+ <Button.Body className="hc-justify-center">
50
+ <Button.Icon icon="mdi:map" size="hc-size-5" />
51
+ Map
52
+ </Button.Body>
53
+ </Button.Btn>
54
+ </Tabs.Trigger>
55
+ )}
56
+ <Tabs.Trigger value="filterTab" asChild onClick={() => setMobileTab("filterTab")}>
57
+ <Button.Btn variant="outline" isBlock className={tabButtonClasses}>
58
+ <Button.Body className="hc-justify-center">
59
+ <Button.Icon icon="fluent:search-12-filled" size="hc-size-5" />
60
+ Filter
61
+ </Button.Body>
62
+ </Button.Btn>
63
+ </Tabs.Trigger>
64
+ </Tabs.List>
65
+ <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="listTab">
66
+ {list}
67
+ </Tabs.Content>
68
+ {showMap && (
69
+ <Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="mapTab">
70
+ {map}
71
+ </Tabs.Content>
72
+ )}
73
+ <Tabs.Content className="hc-grow hc-bg-white hc-outline-none hc-p-2" value="filterTab">
74
+ {filter}
75
+ </Tabs.Content>
76
+ </Tabs.Root>
77
+ </div>
78
+ );
79
+ };
80
+
81
+ export default MapTabs;
@@ -1,8 +1,8 @@
1
- export const placeTypes = {
2
- FOOD: "food",
3
- STORE: "shopping",
4
- TOURIST_ATTRACTION: "attractions",
5
- TRANSIT_STATION: "transit",
6
- SCHOOL: "schools",
7
- PLACE_OF_WORSHIP: "worship"
8
- };
1
+ export const placeTypes = {
2
+ FOOD: "food",
3
+ STORE: "shopping",
4
+ TOURIST_ATTRACTION: "attractions",
5
+ TRANSIT_STATION: "transit",
6
+ SCHOOL: "schools",
7
+ PLACE_OF_WORSHIP: "worship"
8
+ };
@@ -16,20 +16,11 @@ export const MapProvider = ({ children, resetFilters }) => {
16
16
  const [location, setLocation] = useState(getStorageObject('location'));
17
17
  const [center, setCenter] = useState(getStorageObject("center", { lat: 39.8283, lng: -98.5795 }));
18
18
  const [zoom, setZoom] = useState(getStorageObject("zoom", 10));
19
- const [commuteLocation, setCommuteLocation] = useState(getStorageObject('commuteLocation'));
20
19
  const [selectedPlaces, setSelectedPlaces] = useState([]);
21
20
  const [mapInteracted, setMapInteracted] = useState(false);
22
21
  const [firstLoadListItem] = useState(getStorageObject('selectedListItem') ?? { id: "defaultId" });
23
- const [travelTime, setTravelTime] = useState(null);
24
22
  const userSetZoom = useRef(true);
25
23
 
26
- useEffect(() => {
27
- setStorageObject("commuteLocation", commuteLocation);
28
- if (!commuteLocation) {
29
- setTravelTime(null);
30
- }
31
- }, [commuteLocation]);
32
-
33
24
  useEffect(() => {
34
25
  setStorageObject("selectedListItem", selectedListItem);
35
26
  }, [selectedListItem]);
@@ -63,7 +54,6 @@ export const MapProvider = ({ children, resetFilters }) => {
63
54
  setZoom(zoom);
64
55
 
65
56
  }
66
-
67
57
  };
68
58
 
69
59
  const filterReset = () => {
@@ -94,8 +84,6 @@ export const MapProvider = ({ children, resetFilters }) => {
94
84
  zoom,
95
85
  setZoom,
96
86
  selectItem,
97
- commuteLocation,
98
- setCommuteLocation,
99
87
  setSelectedPlaces,
100
88
  selectedPlaces,
101
89
  selectLocationEntity,
@@ -104,8 +92,6 @@ export const MapProvider = ({ children, resetFilters }) => {
104
92
  mapInteracted,
105
93
  userSetZoom,
106
94
  firstLoadListItem,
107
- travelTime,
108
- setTravelTime,
109
95
  filterReset
110
96
  }}
111
97
  >
@@ -37,9 +37,10 @@ export const MapListProvider = ({
37
37
  const [loading, setLoading] = useState(false);
38
38
  const [mapItems, setMapItems] = useState(getStorageObject('mapItems', []));
39
39
  const [query, setQuery] = useState(() => resetFilters ? null : getQuery());
40
+ const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
40
41
  const [listingEntities, setListingEntities] = useState(getStorageObject("listingEntities", null));
41
42
  const [firstLoad, setFirstLoad] = useState(true);
42
- const [commuteLocation, setCommuteLocation] = useState(null);
43
+ const [commuteLocation, setCommuteLocation] = useState(getStorageObject('commuteLocation'));
43
44
  const [selectedFilters, setSelectedFilters] = useState(() => resetFilters ? {} : getStorageObject('selectedFilters', {}));//hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
44
45
  const [filterOptions, setFilterOptions] = useState();
45
46
  const [recruiters, setRecruiters] = useState(getStorageObject("recruiters", {}));
@@ -48,11 +49,25 @@ export const MapListProvider = ({
48
49
  const [favorites, setFavorites] = useState([]);
49
50
  const [filterByFavorites, setFilterByFavorites] = useState(false);
50
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
+
51
62
  useEffect(() => {
52
63
  const loadedFavorites = JSON.parse(localStorage.getItem('favorites')) || [];
53
64
  setFavorites(loadedFavorites);
54
65
  }, []);
55
66
 
67
+ useEffect(() => {
68
+ setStorageObject("commuteLocation", commuteLocation);
69
+ }, [commuteLocation]);
70
+
56
71
  useEffect(() => {
57
72
  if (commuteLocation === null || commuteLocation === '') return;
58
73
  async function fetchEntities() {
@@ -77,7 +92,7 @@ export const MapListProvider = ({
77
92
  newFilteredListings[j].fields.travelTime = fetchedEntities[newFilteredListings[j].entityId].travelTime;
78
93
  }
79
94
  }
80
- setFilteredListings(newFilteredListings);
95
+ setNewFilteredListings(newFilteredListings);
81
96
  } catch (error) {
82
97
  console.error("Failed to fetch listing entities:", error);
83
98
  }
@@ -98,7 +113,7 @@ export const MapListProvider = ({
98
113
  fetchedRecruiters,
99
114
  fetchedEntities,
100
115
  distinctItems
101
- } = await fetchListings(query, siteConfig);
116
+ } = await fetchListings(query, siteConfig, commuteLocation);
102
117
  setAllListings(listingsResult);
103
118
  setRecruiters(fetchedRecruiters);
104
119
  setListingEntities(fetchedEntities);
@@ -128,7 +143,7 @@ export const MapListProvider = ({
128
143
  if (filterByFavorites) {
129
144
  filteredListings = filteredListings.filter(x => favorites.includes(x.id));
130
145
  }
131
- setFilteredListings(filteredListings);
146
+ setNewFilteredListings(filteredListings);
132
147
  // if (firstLoad && hasFiltersInURL(location)) {
133
148
  // const { filters } = filtersFromURL(location);
134
149
  // setSelectedFilters(filters);
@@ -167,12 +182,13 @@ export const MapListProvider = ({
167
182
  }, [selectedFilters, query, listingEntities, filterByFavorites, favorites]);
168
183
 
169
184
  const handleFilterListingsByLocation = selectedLocation => {
170
- const { filteredListings } = filterListingsByLocation(
185
+ let { filteredListings } = filterListingsByLocation(
171
186
  allListings,
172
187
  selectedLocation,
173
188
  listingEntities
174
189
  );
175
- setFilteredListings(filteredListings);
190
+
191
+ setNewFilteredListings(filteredListings);
176
192
  //setMapItems(mapItems);
177
193
  };
178
194
 
@@ -192,7 +208,7 @@ export const MapListProvider = ({
192
208
  filteredListings,
193
209
  mapItems,
194
210
  query,
195
- setFilteredListings,
211
+ setNewFilteredListings,
196
212
  setQuery,
197
213
  listingEntities,
198
214
  selectedFilters,
@@ -214,7 +230,9 @@ export const MapListProvider = ({
214
230
  navigateToDetails,
215
231
  navigateToEasyApply,
216
232
  Link,
217
- linkFormat
233
+ linkFormat,
234
+ sortSetting,
235
+ setSortSetting
218
236
  }}>
219
237
  {children}
220
238
  </MapListContext.Provider>
@@ -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
+ };
@@ -1,9 +1,6 @@
1
1
  import { useEffect, useState, useRef } from 'react';
2
2
 
3
3
  import { getStorageObject } from '~/util/localStorageUtil';
4
- import { dynamicSort } from '~/util/sortUtil';
5
-
6
- import { useMapList } from '~/contexts/mapListContext';
7
4
 
8
5
  const getDefaultItemId = () => {
9
6
  let item = getStorageObject("selectedListItem");
@@ -14,7 +11,7 @@ const getDefaultItemId = () => {
14
11
  }
15
12
  };
16
13
 
17
- const useListLogic = () => {
14
+ const useListLogic = filteredListings => {
18
15
  const [itemLimit, setItemLimit] = useState(100);
19
16
  const [expandedId] = useState(getDefaultItemId());
20
17
  const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
@@ -23,14 +20,6 @@ const useListLogic = () => {
23
20
  const scrollContainerRef = useRef(null);
24
21
  const itemRefs = useRef({});
25
22
  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
23
 
35
24
  useEffect(() => {
36
25
  observer.current = new IntersectionObserver(handleObserver, {
@@ -59,10 +48,9 @@ const useListLogic = () => {
59
48
  if (parseInt(savedScrollPosition) > 3000) {
60
49
  setItemLimit(savedScrollPosition / 10);
61
50
  }
62
- if (savedScrollPosition && scrollPosition != null && scrollContainerRef.current) {
63
- let scrollContainerRefCurrent = scrollContainerRef.current;
51
+ if (savedScrollPosition && scrollContainerRef.current) {
64
52
  setTimeout(() => {
65
- scrollContainerRefCurrent = parseInt(savedScrollPosition, 10);
53
+ scrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);
66
54
  }, 300);
67
55
  }
68
56
  }, []);
@@ -95,7 +83,7 @@ const useListLogic = () => {
95
83
  }
96
84
  };
97
85
 
98
- return { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, dynamicSort, filteredListings };
86
+ return { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, filteredListings };
99
87
  };
100
88
 
101
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
+ };