@abcagency/hc-ui-components 1.3.18 → 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 (191) hide show
  1. package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -1
  2. package/dist/apis/hcApi.js +85 -183
  3. package/dist/apis/hcApi.js.map +1 -1
  4. package/dist/components/HireControlMap.js +10 -5
  5. package/dist/components/HireControlMap.js.map +1 -1
  6. package/dist/components/modules/accordions/MapAccordionItem.js +10 -67
  7. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  8. package/dist/components/modules/filter/index.js.map +1 -1
  9. package/dist/components/modules/filter/radio-item.js +1 -2
  10. package/dist/components/modules/filter/radio-item.js.map +1 -1
  11. package/dist/components/modules/jobListing/listing-details-container.js +45 -0
  12. package/dist/components/modules/jobListing/listing-details-container.js.map +1 -0
  13. package/dist/components/modules/jobListing/listing-details.js +24 -24
  14. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  15. package/dist/components/modules/{maps/list → list}/field-mapper.js +8 -7
  16. package/dist/components/modules/list/field-mapper.js.map +1 -0
  17. package/dist/components/modules/{maps/list → list}/header-item.js +2 -2
  18. package/dist/components/modules/list/header-item.js.map +1 -0
  19. package/dist/components/modules/{maps/list → list}/header.js +6 -4
  20. package/dist/components/modules/list/header.js.map +1 -0
  21. package/dist/components/modules/list/index.js +36 -0
  22. package/dist/components/modules/list/index.js.map +1 -0
  23. package/dist/components/modules/{maps/list → list}/item-expand-card/index.js +3 -1
  24. package/dist/components/modules/list/item-expand-card/index.js.map +1 -0
  25. package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +2 -2
  26. package/dist/components/modules/list/item-expand-card/recruiter-contact-nav.js.map +1 -0
  27. package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +1 -1
  28. package/dist/components/modules/list/item-expand-card/recruiter-details.js.map +1 -0
  29. package/dist/components/modules/list/item-expand-card/recruiter-headshot.js.map +1 -0
  30. package/dist/components/modules/list/item-list.js +28 -0
  31. package/dist/components/modules/list/item-list.js.map +1 -0
  32. package/dist/components/modules/list/list-item/index.js +75 -0
  33. package/dist/components/modules/list/list-item/index.js.map +1 -0
  34. package/dist/components/modules/list/list-item/list-item-container.js +47 -0
  35. package/dist/components/modules/list/list-item/list-item-container.js.map +1 -0
  36. package/dist/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +29 -33
  37. package/dist/components/modules/list/list-item/list-item.js.map +1 -0
  38. package/dist/components/modules/maps/map-list.js +3 -3
  39. package/dist/components/modules/maps/map-list.js.map +1 -1
  40. package/dist/contexts/mapContext.js +84 -113
  41. package/dist/contexts/mapContext.js.map +1 -1
  42. package/dist/contexts/mapListContext.js +181 -293
  43. package/dist/contexts/mapListContext.js.map +1 -1
  44. package/dist/contexts/trackEventContext.js +1 -1
  45. package/dist/services/configService.js +10 -28
  46. package/dist/services/configService.js.map +1 -1
  47. package/dist/services/googlePlacesNearbyService.js +33 -58
  48. package/dist/services/googlePlacesNearbyService.js.map +1 -1
  49. package/dist/services/listingAggregatorService.js +35 -75
  50. package/dist/services/listingAggregatorService.js.map +1 -1
  51. package/dist/services/listingEntityService.js +10 -31
  52. package/dist/services/listingEntityService.js.map +1 -1
  53. package/dist/services/listingService.js +26 -60
  54. package/dist/services/listingService.js.map +1 -1
  55. package/dist/services/recruiterService.js +11 -31
  56. package/dist/services/recruiterService.js.map +1 -1
  57. package/dist/types/apis/hcApi.d.ts +5 -0
  58. package/dist/types/clientToken.d.ts +2 -0
  59. package/dist/types/components/modules/accordions/MapAccordionItem.d.ts +9 -0
  60. package/dist/types/components/modules/accordions/default.d.ts +19 -0
  61. package/dist/types/components/modules/buttons/button-group-apply.d.ts +24 -0
  62. package/dist/types/components/modules/buttons/commute-pill.d.ts +5 -0
  63. package/dist/types/components/modules/buttons/default.d.ts +48 -0
  64. package/dist/types/components/modules/buttons/pill-wrapper.d.ts +3 -0
  65. package/dist/types/components/modules/dialogs/apply-dialog.d.ts +8 -0
  66. package/dist/types/components/modules/filter/sort.d.ts +8 -0
  67. package/dist/types/components/modules/grid.d.ts +8 -0
  68. package/dist/types/components/modules/icon.d.ts +10 -0
  69. package/dist/types/components/modules/jobListing/listing-details-container.d.ts +6 -0
  70. package/dist/types/components/modules/jobListing/listing-details.d.ts +18 -0
  71. package/dist/types/components/modules/list/field-mapper.d.ts +10 -0
  72. package/dist/types/components/modules/list/header-item.d.ts +11 -0
  73. package/dist/types/components/modules/list/header.d.ts +11 -0
  74. package/dist/types/components/modules/list/index.d.ts +9 -0
  75. package/dist/types/components/modules/list/item-expand-card/index.d.ts +7 -0
  76. package/dist/types/components/modules/list/item-expand-card/recruiter-contact-nav.d.ts +17 -0
  77. package/dist/types/components/modules/list/item-expand-card/recruiter-details.d.ts +21 -0
  78. package/dist/types/components/modules/list/item-expand-card/recruiter-headshot.d.ts +8 -0
  79. package/dist/types/components/modules/list/item-list.d.ts +21 -0
  80. package/dist/types/components/modules/list/list-item/index.d.ts +12 -0
  81. package/dist/types/components/modules/list/list-item/list-item-container.d.ts +14 -0
  82. package/dist/types/components/modules/list/list-item/list-item.d.ts +3 -0
  83. package/dist/types/constants/eventTypes.d.ts +13 -0
  84. package/dist/types/contexts/mapContext.d.ts +29 -0
  85. package/dist/types/contexts/mapListContext.d.ts +58 -0
  86. package/dist/types/contexts/trackEventContext.d.ts +6 -0
  87. package/dist/types/enums/SectionType.d.ts +9 -0
  88. package/dist/types/hooks/useList.d.ts +13 -0
  89. package/dist/types/services/configService.d.ts +6 -0
  90. package/dist/types/services/googlePlacesNearbyService.d.ts +5 -0
  91. package/dist/types/services/listingAggregatorService.d.ts +12 -0
  92. package/dist/types/services/listingEntityService.d.ts +6 -0
  93. package/dist/types/services/listingService.d.ts +9 -0
  94. package/dist/types/services/recruiterService.d.ts +6 -0
  95. package/dist/types/types/Address.d.ts +7 -0
  96. package/dist/types/types/ContentSection.d.ts +8 -0
  97. package/dist/types/types/GetListingParams.d.ts +8 -0
  98. package/dist/types/types/LatLng.d.ts +4 -0
  99. package/dist/types/types/ListingEntity.d.ts +10 -0
  100. package/dist/types/types/ListingFields.d.ts +20 -0
  101. package/dist/types/types/Listings.d.ts +31 -0
  102. package/dist/types/types/Recruiter.d.ts +9 -0
  103. package/dist/types/types/SimilarListing.d.ts +24 -0
  104. package/dist/types/types/config/Colors.d.ts +8 -0
  105. package/dist/types/types/config/MapConfig.d.ts +29 -0
  106. package/dist/types/types/config/PointsOfInterestConfig.d.ts +13 -0
  107. package/dist/types/types/config/SearchConfig.d.ts +4 -0
  108. package/dist/types/util/filterUtil.d.ts +28 -0
  109. package/dist/types/util/loading.d.ts +3 -0
  110. package/dist/types/util/localStorageUtil.d.ts +3 -0
  111. package/dist/types/util/mapUtil.d.ts +15 -0
  112. package/dist/types/util/sortUtil.d.ts +1 -0
  113. package/dist/types/util/stringUtils.d.ts +1 -0
  114. package/dist/util/filterUtil.js +1 -3
  115. package/dist/util/filterUtil.js.map +1 -1
  116. package/dist/util/localStorageUtil.js +37 -28
  117. package/dist/util/localStorageUtil.js.map +1 -1
  118. package/dist/util/mapUtil.js.map +1 -1
  119. package/package.json +23 -17
  120. package/rollup.config.mjs +23 -19
  121. package/src/apis/{hcApi.js → hcApi.ts} +27 -11
  122. package/src/components/HireControlMap.js +132 -129
  123. package/src/components/modules/accordions/MapAccordionItem.js +32 -74
  124. package/src/components/modules/filter/index.js +89 -89
  125. package/src/components/modules/filter/radio-item.js +0 -1
  126. package/src/components/modules/jobListing/listing-details-container.js +40 -0
  127. package/src/components/modules/jobListing/listing-details.js +209 -99
  128. package/src/components/modules/{maps/list → list}/field-mapper.js +114 -112
  129. package/src/components/modules/{maps/list → list}/header.js +49 -47
  130. package/src/components/modules/list/index.tsx +83 -0
  131. package/src/components/modules/{maps/list → list}/item-expand-card/index.js +24 -22
  132. package/src/components/modules/list/item-list.tsx +198 -0
  133. package/src/components/modules/list/list-item/index.js +70 -0
  134. package/src/components/modules/list/list-item/list-item-container.js +43 -0
  135. package/src/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +32 -38
  136. package/src/components/modules/maps/map-list.js +74 -74
  137. package/src/contexts/mapContext.tsx +129 -0
  138. package/src/contexts/mapListContext.tsx +297 -0
  139. package/src/enums/SectionType.ts +9 -0
  140. package/src/services/{configService.js → configService.ts} +16 -16
  141. package/src/services/{googlePlacesNearbyService.js → googlePlacesNearbyService.ts} +11 -2
  142. package/src/services/listingAggregatorService.ts +76 -0
  143. package/src/services/listingEntityService.ts +16 -0
  144. package/src/services/listingService.ts +40 -0
  145. package/src/services/{recruiterService.js → recruiterService.ts} +18 -17
  146. package/src/types/Address.ts +7 -0
  147. package/src/types/ContentSection.ts +9 -0
  148. package/src/types/GetListingParams.ts +8 -0
  149. package/src/types/LatLng.ts +4 -0
  150. package/src/types/ListingEntity.ts +11 -0
  151. package/src/types/ListingFields.ts +20 -0
  152. package/src/types/Listings.ts +32 -0
  153. package/src/types/Recruiter.ts +9 -0
  154. package/src/types/SimilarListing.ts +24 -0
  155. package/src/types/config/Colors.ts +8 -0
  156. package/src/types/config/MapConfig.ts +30 -0
  157. package/src/types/config/PointsOfInterestConfig.ts +13 -0
  158. package/src/types/config/SearchConfig.ts +4 -0
  159. package/src/util/filterUtil.js +239 -239
  160. package/src/util/localStorageUtil.ts +34 -0
  161. package/src/util/mapUtil.js +91 -91
  162. package/tsconfig.json +23 -0
  163. package/dist/components/modules/maps/list/field-mapper.js.map +0 -1
  164. package/dist/components/modules/maps/list/header-item.js.map +0 -1
  165. package/dist/components/modules/maps/list/header.js.map +0 -1
  166. package/dist/components/modules/maps/list/index.js +0 -102
  167. package/dist/components/modules/maps/list/index.js.map +0 -1
  168. package/dist/components/modules/maps/list/item-expand-card/index.js.map +0 -1
  169. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +0 -1
  170. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +0 -1
  171. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +0 -1
  172. package/dist/components/modules/maps/list/list-item/index.js.map +0 -1
  173. package/dist/services/_virtual/_rollupPluginBabelHelpers.js +0 -372
  174. package/dist/services/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  175. package/dist/services/apis/hcApi.js +0 -189
  176. package/dist/services/apis/hcApi.js.map +0 -1
  177. package/dist/services/clientToken.js +0 -7
  178. package/dist/services/clientToken.js.map +0 -1
  179. package/dist/services/styles/index.css +0 -3
  180. package/src/components/modules/maps/list/index.js +0 -112
  181. package/src/contexts/mapContext.js +0 -101
  182. package/src/contexts/mapListContext.js +0 -242
  183. package/src/services/listingAggregatorService.js +0 -50
  184. package/src/services/listingEntityService.js +0 -15
  185. package/src/services/listingService.js +0 -26
  186. package/src/util/localStorageUtil.js +0 -27
  187. /package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
  188. /package/src/components/modules/{maps/list → list}/header-item.js +0 -0
  189. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +0 -0
  190. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +0 -0
  191. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
@@ -1,74 +1,74 @@
1
- import React from 'react';
2
-
3
- import List from '~/components/modules/maps/list';
4
- import Map from '~/components/modules/maps/map';
5
- import Tabs from '~/components/modules/maps/tabs';
6
- import Filter from '~/components/modules/filter';
7
-
8
- const MapList = ({
9
- loading = false,
10
- mapDetails,
11
- markerConfigs,
12
- itemExpandedContent,
13
- fieldsShown,
14
- specialFeatures,
15
- fieldNames,
16
- showMap,
17
- placeMappings
18
- }) => {
19
-
20
- const listProps = {
21
- fieldsShown: fieldsShown,
22
- fieldNames: fieldNames,
23
- itemExpandedContent: itemExpandedContent,
24
- loading: loading,
25
- showMap: showMap,
26
- specialFeatures: specialFeatures
27
- };
28
-
29
- const mapProps = {
30
- mapDetails: mapDetails,
31
- markerConfigs: markerConfigs,
32
- placeMappings: placeMappings,
33
- clusterGridSize: 60,
34
- showMap: showMap
35
- };
36
-
37
- // useEffect(() => {
38
- // if (selectedItem !== null) {
39
- // trackEvent("Map", "View Location", selectedItem[titlePropName]);
40
- // }
41
- // // eslint-disable-next-line react-hooks/exhaustive-deps
42
- // }, []);
43
- const map = <Map {...mapProps} />;
44
- return (
45
- <>
46
- <div
47
- className={`
48
- ${showMap == false ? "md:hc-grid-rows-[100vh]" : "md:hc-grid-rows-[50vh_50vh]"}
49
- md:hc-grid md:hc-pt-4 hc-overflow-hidden hc-relative bg-gray-100
50
- `}
51
- >
52
- <div>
53
- <List {...listProps} />
54
- </div>
55
- <div>{showMap && map}</div>
56
- </div>
57
- <div className="md:hc-hidden">
58
- <Tabs
59
- showMap={showMap}
60
- list={<List {...listProps} />}
61
- map={!loading && showMap && map}
62
- filter={
63
- <Filter
64
- showMap={showMap}
65
- className="md:hc-hidden"
66
- />
67
- }
68
- />
69
- </div>
70
- </>
71
- );
72
- };
73
-
74
- export default MapList;
1
+ import React from 'react';
2
+
3
+ import List from '~/components/modules/list';
4
+ import Map from '~/components/modules/maps/map';
5
+ import Tabs from '~/components/modules/maps/tabs';
6
+ import Filter from '~/components/modules/filter';
7
+
8
+ const MapList = ({
9
+ loading = false,
10
+ mapDetails,
11
+ markerConfigs,
12
+ itemExpandedContent,
13
+ fieldsShown,
14
+ specialFeatures,
15
+ fieldNames,
16
+ showMap,
17
+ placeMappings
18
+ }) => {
19
+
20
+ const listProps = {
21
+ fieldsShown: fieldsShown,
22
+ fieldNames: fieldNames,
23
+ itemExpandedContent: itemExpandedContent,
24
+ loading: loading,
25
+ showMap: showMap,
26
+ specialFeatures: specialFeatures
27
+ };
28
+
29
+ const mapProps = {
30
+ mapDetails: mapDetails,
31
+ markerConfigs: markerConfigs,
32
+ placeMappings: placeMappings,
33
+ clusterGridSize: 60,
34
+ showMap: showMap
35
+ };
36
+
37
+ // useEffect(() => {
38
+ // if (selectedItem !== null) {
39
+ // trackEvent("Map", "View Location", selectedItem[titlePropName]);
40
+ // }
41
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
42
+ // }, []);
43
+ const map = <Map {...mapProps} />;
44
+ return (
45
+ <>
46
+ <div
47
+ className={`
48
+ ${showMap == false ? "md:hc-grid-rows-[100vh]" : "md:hc-grid-rows-[50vh_50vh]"}
49
+ md:hc-grid md:hc-pt-4 hc-overflow-hidden hc-relative bg-gray-100
50
+ `}
51
+ >
52
+ <div>
53
+ <List {...listProps} />
54
+ </div>
55
+ <div>{showMap && map}</div>
56
+ </div>
57
+ <div className="md:hc-hidden">
58
+ <Tabs
59
+ showMap={showMap}
60
+ list={<List {...listProps} />}
61
+ map={!loading && showMap && map}
62
+ filter={
63
+ <Filter
64
+ showMap={showMap}
65
+ className="md:hc-hidden"
66
+ />
67
+ }
68
+ />
69
+ </div>
70
+ </>
71
+ );
72
+ };
73
+
74
+ export default MapList;
@@ -0,0 +1,129 @@
1
+ import React, { createContext, useState, useContext, useEffect, useRef, ReactNode } from 'react';
2
+ import { getStorageObject, setStorageObject } from '~/util/localStorageUtil';
3
+ import { Listing } from '~/types/Listings';
4
+ import { LatLng } from '~/types/LatLng';
5
+ interface IMapContext {
6
+ selectedListItem: Listing | null;
7
+ setSelectedListItem: (item: Listing | null) => void;
8
+ location: any | null;
9
+ setLocation: (location: LatLng | null) => void;
10
+ center: LatLng;
11
+ setCenter: (center: LatLng) => void;
12
+ zoom: number;
13
+ setZoom: (zoom: number) => void;
14
+ selectedPlaces: string[];
15
+ setSelectedPlaces: (places: string[]) => void;
16
+ mapInteracted: boolean;
17
+ setMapInteracted: (interacted: boolean) => void;
18
+ userSetZoom: React.MutableRefObject<boolean>;
19
+ firstLoadListItem: any;
20
+ selectItem: (item: Listing, itemLocation: LatLng | null, zoom: number, center: LatLng) => void;
21
+ filterReset: () => void;
22
+ selectLocationEntity: (location: LatLng) => void;
23
+ }
24
+
25
+ const MapContext = createContext<IMapContext | undefined>(undefined);
26
+
27
+ export const useMap = () => {
28
+ const context = useContext(MapContext);
29
+ if (!context) {
30
+ throw new Error("useMap must be used within a MapProvider");
31
+ }
32
+ return context;
33
+ };
34
+
35
+ interface MapProviderProps {
36
+ children: ReactNode;
37
+ resetFilters: boolean;
38
+ }
39
+
40
+ export const MapProvider: React.FC<MapProviderProps> = ({ children, resetFilters }) => {
41
+ const [selectedListItem, setSelectedListItem] = useState<Listing | null>(getStorageObject('selectedListItem'));
42
+ const [location, setLocation] = useState<any>(getStorageObject('location'));
43
+ const [center, setCenter] = useState<LatLng>(getStorageObject("center", { lat: 39.8283, lng: -98.5795 }) || { lat: 39.8283, lng: -98.5795 });
44
+ const [zoom, setZoom] = useState<number>(getStorageObject("zoom", 10) || 10);
45
+ const [selectedPlaces, setSelectedPlaces] = useState<string[]>([]);
46
+ const [mapInteracted, setMapInteracted] = useState<boolean>(false);
47
+ const [firstLoadListItem] = useState<any>(getStorageObject('selectedListItem', { id: "defaultId" }));
48
+ const userSetZoom = useRef<boolean>(true);
49
+
50
+ useEffect(() => {
51
+ setStorageObject("selectedListItem", selectedListItem);
52
+ }, [selectedListItem]);
53
+
54
+ useEffect(() => {
55
+ localStorage.setItem("zoom", zoom.toString());
56
+ }, [zoom]);
57
+
58
+ useEffect(() => {
59
+ if (location == null) {
60
+ localStorage.removeItem("location");
61
+ } else {
62
+ setStorageObject("location", location);
63
+ }
64
+ }, [location]);
65
+
66
+ useEffect(() => {
67
+ setStorageObject("center", center);
68
+ }, [center]);
69
+
70
+ const selectItem = (item: Listing, itemLocation: LatLng | null, zoom: number, center: LatLng) => {
71
+ setSelectedListItem(item);
72
+ if (mapInteracted === false && itemLocation != null) {
73
+ setLocation(itemLocation);
74
+ }
75
+ if (mapInteracted === false || itemLocation != null) {
76
+ setLocation(itemLocation);
77
+ setCenter(center);
78
+ }
79
+ if (mapInteracted === false) {
80
+ setZoom(zoom);
81
+ }
82
+ };
83
+
84
+ const filterReset = () => {
85
+ setSelectedPlaces([]);
86
+ setSelectedListItem(null);
87
+ setLocation(null);
88
+ setZoom(8);
89
+ setMapInteracted(false);
90
+ };
91
+
92
+ useEffect(() => {
93
+ if (resetFilters === true) {
94
+ filterReset();
95
+ }
96
+ }, [resetFilters]);
97
+
98
+ const selectLocationEntity = (location: LatLng) => {
99
+ localStorage.removeItem("selectedListItem");
100
+ setTimeout(() => setLocation(location), 200);
101
+ setSelectedListItem(null);
102
+ };
103
+
104
+ return (
105
+ <MapContext.Provider
106
+ value={{
107
+ selectedListItem,
108
+ setSelectedListItem,
109
+ location,
110
+ center,
111
+ setCenter,
112
+ zoom,
113
+ setZoom,
114
+ selectItem,
115
+ setSelectedPlaces,
116
+ selectedPlaces,
117
+ selectLocationEntity,
118
+ setLocation,
119
+ setMapInteracted,
120
+ mapInteracted,
121
+ userSetZoom,
122
+ firstLoadListItem,
123
+ filterReset
124
+ }}
125
+ >
126
+ {children}
127
+ </MapContext.Provider>
128
+ );
129
+ };
@@ -0,0 +1,297 @@
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
+
6
+ import { getListingEntities } from "~/services/listingEntityService";
7
+ import fetchListings from '~/services/listingAggregatorService';
8
+
9
+ import { Listing } from '~/types/Listings';
10
+ import { ListingEntity } from '~/types/ListingEntity';
11
+ import { Recruiter } from '~/types/Recruiter';
12
+ import { MapConfig, MapConfig as SiteConfig } from '~/types/config/MapConfig';
13
+
14
+ interface MapListContextProps {
15
+ loading: boolean;
16
+ allListings: Listing[];
17
+ filteredListings: Listing[];
18
+ mapItems: any;
19
+ query: string | null;
20
+ setNewFilteredListings: (filteredListings: Listing[]) => void;
21
+ setQuery: (query: string | null) => void;
22
+ listingEntities: Record<number, ListingEntity> | null;
23
+ selectedFilters: Record<string, any>;
24
+ setSelectedFilters: (filters: Record<string, any>) => void;
25
+ filterOptions: any;
26
+ recruiters: Record<number, Recruiter>;
27
+ handleFilterListingsByLocation: (selectedLocation: any) => void;
28
+ filterDialogIsOpen: boolean;
29
+ setFilterDialogIsOpen: (isOpen: boolean) => void;
30
+ setMobileTab: (tab: string) => void;
31
+ mobileTab: string;
32
+ siteConfig: SiteConfig;
33
+ favorites: number[];
34
+ handleSettingFavorites: (favorites: number[] | null) => void;
35
+ setFilterByFavorites: (filter: boolean) => void;
36
+ filterByFavorites: boolean;
37
+ commuteLocation: any | null;
38
+ setCommuteLocation: (location: any | null) => void;
39
+ navigateToDetails: (id: number) => void;
40
+ navigateToEasyApply: (id: number) => void;
41
+ Link: React.ComponentType<any>;
42
+ linkFormat: string;
43
+ sortSetting: { field: string; type: string };
44
+ setSortSetting: (setting: { field: string; type: string }) => void;
45
+ trackEvent: (event: string) => void;
46
+ }
47
+
48
+ const MapListContext = createContext<MapListContextProps | undefined>(undefined);
49
+
50
+ export const useMapList = () => {
51
+ const context = useContext(MapListContext);
52
+ if (!context) {
53
+ throw new Error('useMapList must be used within a MapListProvider');
54
+ }
55
+ return context;
56
+ };
57
+
58
+ const getQuery = (): string | null => {
59
+ let query: string | null = null;
60
+ if (typeof window !== 'undefined') {
61
+ query = localStorage.getItem('query');
62
+ }
63
+ return query;
64
+ };
65
+
66
+ interface MapListProviderProps {
67
+ children: ReactNode;
68
+ siteConfig: MapConfig;
69
+ resetFilters: boolean;
70
+ navigateToDetails: (id: number) => void;
71
+ navigateToEasyApply: (id: number) => void;
72
+ Link: React.ComponentType<any>;
73
+ linkFormat: string;
74
+ trackEvent: (event: string) => void;
75
+ listings?: Listing[];
76
+ }
77
+
78
+ export const MapListProvider: React.FC<MapListProviderProps> = ({
79
+ children,
80
+ siteConfig,
81
+ resetFilters,
82
+ navigateToDetails,
83
+ navigateToEasyApply,
84
+ Link,
85
+ linkFormat,
86
+ trackEvent,
87
+ listings = []
88
+ }) => {
89
+ const [allListings, setAllListings] = useState<Listing[]>(getStorageObject("listings", listings) || []);
90
+ const [filteredListings, setFilteredListings] = useState<Listing[]>([]);
91
+ const [loading, setLoading] = useState<boolean>(false);
92
+ const [mapItems, setMapItems] = useState<any>(getStorageObject('mapItems', []) || []);
93
+ const [query, setQuery] = useState<string | null>(() => resetFilters ? null : getQuery());
94
+ const [sortSetting, setSortSetting] = useState<{ field: string; type: string }>(getStorageObject('sortSetting', { field: 'position', type: 'asc' }) || { field: 'position', type: 'asc' });
95
+ const [listingEntities, setListingEntities] = useState<Record<number, ListingEntity> | null>(getStorageObject("listingEntities", null));
96
+ const [firstLoad, setFirstLoad] = useState<boolean>(true);
97
+ const [commuteLocation, setCommuteLocation] = useState<any | null>(getStorageObject('commuteLocation'));
98
+ const [selectedFilters, setSelectedFilters] = useState<Record<string, any>>(() => resetFilters ? {} : getStorageObject('selectedFilters', {}) || {});
99
+ const [filterOptions, setFilterOptions] = useState<any>();
100
+ const [recruiters, setRecruiters] = useState<Record<number, Recruiter>>(getStorageObject("recruiters", {}) || {});
101
+ const [filterDialogIsOpen, setFilterDialogIsOpen] = useState<boolean>(false);
102
+ const [mobileTab, setMobileTab] = useState<string>("listTab");
103
+ const [favorites, setFavorites] = useState<number[]>([]);
104
+ const [filterByFavorites, setFilterByFavorites] = useState<boolean>(false);
105
+
106
+ const setNewFilteredListings = (filteredListings: Listing[]) => {
107
+ setFilteredListings(filteredListings);
108
+ };
109
+
110
+ useEffect(() => {
111
+ if (!sortSetting) return;
112
+ localStorage.setItem('sortSetting', JSON.stringify(sortSetting));
113
+ setNewFilteredListings(filteredListings);
114
+ }, [sortSetting]);
115
+
116
+ useEffect(() => {
117
+ const loadedFavorites = JSON.parse(localStorage.getItem('favorites') || '[]');
118
+ setFavorites(loadedFavorites);
119
+ }, []);
120
+
121
+ useEffect(() => {
122
+ setStorageObject("commuteLocation", commuteLocation);
123
+ }, [commuteLocation]);
124
+
125
+ useEffect(() => {
126
+ if (!commuteLocation) return;
127
+
128
+ async function fetchEntities() {
129
+ const distinctEntityIds = [
130
+ ...new Set(allListings.map(listing => listing.entityId ?? -1))
131
+ ];
132
+ try {
133
+ const fetchedEntities = await getListingEntities(
134
+ distinctEntityIds,
135
+ `${commuteLocation.lat}, ${commuteLocation.lng}`
136
+ );
137
+ setListingEntities(fetchedEntities);
138
+ const newFilteredListings: Listing[] = [...filteredListings] ?? [];
139
+ for (let i = 0; i < allListings.length; i++) {
140
+ const listing = newFilteredListings[i];
141
+ if (
142
+ listing &&
143
+ listing.fields &&
144
+ listing.entityId !== undefined &&
145
+ listing.entityId !== -1
146
+ ) {
147
+ const entityId = listing.entityId;
148
+ const travelTime = fetchedEntities[entityId]?.travelTime;
149
+
150
+ if (travelTime !== undefined && listing.fields) {
151
+ listing.fields.travelTime = travelTime;
152
+ }
153
+ }
154
+ }
155
+
156
+ setNewFilteredListings(newFilteredListings);
157
+ } catch (error) {
158
+ console.error("Failed to fetch listing entities:", error);
159
+ }
160
+ }
161
+
162
+ fetchEntities();
163
+ }, [commuteLocation, allListings, siteConfig.companyId]);
164
+
165
+ useEffect(() => {
166
+ const handleFetchListings = async () => {
167
+ if (!getStorageObject('listings') ?? [].length) {
168
+ setLoading(true);
169
+ }
170
+
171
+ try {
172
+ const {
173
+ listingsResult,
174
+ fetchedRecruiters,
175
+ fetchedEntities,
176
+ distinctItems
177
+ } = await fetchListings(query ?? '', siteConfig, commuteLocation);
178
+ setAllListings(listingsResult);
179
+ setRecruiters(fetchedRecruiters);
180
+ setListingEntities(fetchedEntities);
181
+ setMapItems(distinctItems);
182
+ setStorageObject("mapItems", distinctItems);
183
+ setStorageObject("listingEntities", fetchedEntities);
184
+ setStorageObject("recruiters", fetchedRecruiters);
185
+ setStorageObject("listings", listingsResult);
186
+ } catch (error) {
187
+ console.log(error);
188
+ }
189
+ setLoading(false);
190
+ };
191
+ handleFetchListings();
192
+ }, [query, siteConfig]);
193
+
194
+ useEffect(() => {
195
+ const processListings = () => {
196
+ let filteredListings: Listing[];
197
+ const { mapItems, filteredListings: tempFilteredListings } = applyFilters(
198
+ allListings,
199
+ selectedFilters,
200
+ query,
201
+ listingEntities,
202
+ favorites,
203
+ siteConfig
204
+ );
205
+ filteredListings = tempFilteredListings;
206
+
207
+ if (filterByFavorites) {
208
+ filteredListings = filteredListings.filter((x: Listing) => favorites.includes(x.id));
209
+ }
210
+ setNewFilteredListings(filteredListings);
211
+ if (firstLoad && selectedFilters) {
212
+ // Update URL with filters if needed
213
+ } else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
214
+ localStorage.removeItem('selectedFilters');
215
+ } else if (!firstLoad) {
216
+ setStorageObject('selectedFilters', selectedFilters);
217
+ }
218
+ query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
219
+ setMapItems(mapItems);
220
+
221
+ if (selectedFilters) {
222
+ const keys = Object.keys(selectedFilters);
223
+ const lastKey = keys[keys.length - 1];
224
+ const options = generateFilterOptions(
225
+ firstLoad ? allListings : filteredListings,
226
+ allListings,
227
+ siteConfig,
228
+ filterOptions,
229
+ lastKey,
230
+ favorites
231
+ );
232
+ if (options) {
233
+ setFilterOptions(options);
234
+ if (firstLoad) setFirstLoad(false);
235
+ }
236
+ }
237
+ };
238
+
239
+ processListings();
240
+ }, [selectedFilters, query, listingEntities, filterByFavorites, favorites]);
241
+
242
+ const handleFilterListingsByLocation = (selectedLocation: any) => {
243
+ const { filteredListings } = filterListingsByLocation(
244
+ allListings,
245
+ selectedLocation,
246
+ listingEntities
247
+ );
248
+ setNewFilteredListings(filteredListings);
249
+ };
250
+
251
+ const handleSettingFavorites = (newFavorites: number[] | null) => {
252
+ if (newFavorites == null) {
253
+ localStorage.removeItem('favorites');
254
+ } else {
255
+ setFavorites(newFavorites);
256
+ localStorage.setItem('favorites', JSON.stringify(newFavorites));
257
+ }
258
+ };
259
+
260
+ return (
261
+ <MapListContext.Provider value={{
262
+ loading,
263
+ allListings,
264
+ filteredListings,
265
+ mapItems,
266
+ query,
267
+ setNewFilteredListings,
268
+ setQuery,
269
+ listingEntities,
270
+ selectedFilters,
271
+ setSelectedFilters,
272
+ filterOptions,
273
+ recruiters,
274
+ handleFilterListingsByLocation,
275
+ filterDialogIsOpen,
276
+ setFilterDialogIsOpen,
277
+ setMobileTab,
278
+ mobileTab,
279
+ siteConfig,
280
+ favorites,
281
+ handleSettingFavorites,
282
+ setFilterByFavorites,
283
+ filterByFavorites,
284
+ commuteLocation,
285
+ setCommuteLocation,
286
+ navigateToDetails,
287
+ navigateToEasyApply,
288
+ Link,
289
+ linkFormat,
290
+ sortSetting,
291
+ setSortSetting,
292
+ trackEvent
293
+ }}>
294
+ {children}
295
+ </MapListContext.Provider>
296
+ );
297
+ };
@@ -0,0 +1,9 @@
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,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
+ 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,8 +1,17 @@
1
- export const searchNearbyPlaces = async (typesArray, location, radius) => {
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> => {
2
11
  const url = 'https://places.googleapis.com/v1/places:searchNearby';
3
12
  const headers = {
4
13
  'Content-Type': 'application/json',
5
- 'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY,
14
+ 'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY as string,
6
15
  'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
7
16
  };
8
17
  const data = {