@abcagency/hc-ui-components 1.3.17 → 1.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/dist/apis/hcApi.js +85 -183
  2. package/dist/apis/hcApi.js.map +1 -1
  3. package/dist/components/HireControlMap.js +10 -5
  4. package/dist/components/HireControlMap.js.map +1 -1
  5. package/dist/components/modules/accordions/MapAccordionItem.js +10 -67
  6. package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
  7. package/dist/components/modules/filter/index.js.map +1 -1
  8. package/dist/components/modules/filter/radio-item.js +1 -2
  9. package/dist/components/modules/filter/radio-item.js.map +1 -1
  10. package/dist/components/modules/filter/search.js +4 -4
  11. package/dist/components/modules/filter/search.js.map +1 -1
  12. package/dist/components/modules/jobListing/listing-details-container.js +45 -0
  13. package/dist/components/modules/jobListing/listing-details-container.js.map +1 -0
  14. package/dist/components/modules/jobListing/listing-details.js +24 -24
  15. package/dist/components/modules/jobListing/listing-details.js.map +1 -1
  16. package/dist/components/modules/{maps/list → list}/field-mapper.js +8 -7
  17. package/dist/components/modules/list/field-mapper.js.map +1 -0
  18. package/dist/components/modules/{maps/list → list}/header-item.js +2 -2
  19. package/dist/components/modules/list/header-item.js.map +1 -0
  20. package/dist/components/modules/{maps/list → list}/header.js +6 -4
  21. package/dist/components/modules/list/header.js.map +1 -0
  22. package/dist/components/modules/list/index.js +36 -0
  23. package/dist/components/modules/list/index.js.map +1 -0
  24. package/dist/components/modules/{maps/list → list}/item-expand-card/index.js +3 -1
  25. package/dist/components/modules/list/item-expand-card/index.js.map +1 -0
  26. package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +2 -2
  27. package/dist/components/modules/list/item-expand-card/recruiter-contact-nav.js.map +1 -0
  28. package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +1 -1
  29. package/dist/components/modules/list/item-expand-card/recruiter-details.js.map +1 -0
  30. package/dist/components/modules/list/item-expand-card/recruiter-headshot.js.map +1 -0
  31. package/dist/components/modules/list/item-list.js +28 -0
  32. package/dist/components/modules/list/item-list.js.map +1 -0
  33. package/dist/components/modules/list/list-item/index.js +75 -0
  34. package/dist/components/modules/list/list-item/index.js.map +1 -0
  35. package/dist/components/modules/list/list-item/list-item-container.js +47 -0
  36. package/dist/components/modules/list/list-item/list-item-container.js.map +1 -0
  37. package/dist/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +29 -33
  38. package/dist/components/modules/list/list-item/list-item.js.map +1 -0
  39. package/dist/components/modules/maps/map-list.js +3 -3
  40. package/dist/components/modules/maps/map-list.js.map +1 -1
  41. package/dist/constants/eventTypes.js +1 -1
  42. package/dist/constants/eventTypes.js.map +1 -1
  43. package/dist/contexts/mapContext.js +84 -113
  44. package/dist/contexts/mapContext.js.map +1 -1
  45. package/dist/contexts/mapListContext.js +181 -290
  46. package/dist/contexts/mapListContext.js.map +1 -1
  47. package/dist/contexts/trackEventContext.js +1 -1
  48. package/dist/services/configService.js +10 -28
  49. package/dist/services/configService.js.map +1 -1
  50. package/dist/services/googlePlacesNearbyService.js +33 -58
  51. package/dist/services/googlePlacesNearbyService.js.map +1 -1
  52. package/dist/services/listingAggregatorService.js +35 -75
  53. package/dist/services/listingAggregatorService.js.map +1 -1
  54. package/dist/services/listingEntityService.js +10 -31
  55. package/dist/services/listingEntityService.js.map +1 -1
  56. package/dist/services/listingService.js +26 -60
  57. package/dist/services/listingService.js.map +1 -1
  58. package/dist/services/recruiterService.js +11 -31
  59. package/dist/services/recruiterService.js.map +1 -1
  60. package/dist/types/apis/hcApi.d.ts +5 -0
  61. package/dist/types/clientToken.d.ts +2 -0
  62. package/dist/types/components/modules/accordions/MapAccordionItem.d.ts +9 -0
  63. package/dist/types/components/modules/accordions/default.d.ts +19 -0
  64. package/dist/types/components/modules/buttons/button-group-apply.d.ts +24 -0
  65. package/dist/types/components/modules/buttons/commute-pill.d.ts +5 -0
  66. package/dist/types/components/modules/buttons/default.d.ts +48 -0
  67. package/dist/types/components/modules/buttons/pill-wrapper.d.ts +3 -0
  68. package/dist/types/components/modules/dialogs/apply-dialog.d.ts +8 -0
  69. package/dist/types/components/modules/filter/sort.d.ts +8 -0
  70. package/dist/types/components/modules/grid.d.ts +8 -0
  71. package/dist/types/components/modules/icon.d.ts +10 -0
  72. package/dist/types/components/modules/jobListing/listing-details-container.d.ts +6 -0
  73. package/dist/types/components/modules/jobListing/listing-details.d.ts +18 -0
  74. package/dist/types/components/modules/list/field-mapper.d.ts +10 -0
  75. package/dist/types/components/modules/list/header-item.d.ts +11 -0
  76. package/dist/types/components/modules/list/header.d.ts +11 -0
  77. package/dist/types/components/modules/list/index.d.ts +9 -0
  78. package/dist/types/components/modules/list/item-expand-card/index.d.ts +7 -0
  79. package/dist/types/components/modules/list/item-expand-card/recruiter-contact-nav.d.ts +17 -0
  80. package/dist/types/components/modules/list/item-expand-card/recruiter-details.d.ts +21 -0
  81. package/dist/types/components/modules/list/item-expand-card/recruiter-headshot.d.ts +8 -0
  82. package/dist/types/components/modules/list/item-list.d.ts +21 -0
  83. package/dist/types/components/modules/list/list-item/index.d.ts +12 -0
  84. package/dist/types/components/modules/list/list-item/list-item-container.d.ts +14 -0
  85. package/dist/types/components/modules/list/list-item/list-item.d.ts +3 -0
  86. package/dist/types/constants/eventTypes.d.ts +13 -0
  87. package/dist/types/contexts/mapContext.d.ts +29 -0
  88. package/dist/types/contexts/mapListContext.d.ts +58 -0
  89. package/dist/types/contexts/trackEventContext.d.ts +6 -0
  90. package/dist/types/enums/SectionType.d.ts +9 -0
  91. package/dist/types/hooks/useList.d.ts +13 -0
  92. package/dist/types/services/configService.d.ts +6 -0
  93. package/dist/types/services/googlePlacesNearbyService.d.ts +5 -0
  94. package/dist/types/services/listingAggregatorService.d.ts +12 -0
  95. package/dist/types/services/listingEntityService.d.ts +6 -0
  96. package/dist/types/services/listingService.d.ts +9 -0
  97. package/dist/types/services/recruiterService.d.ts +6 -0
  98. package/dist/types/types/Address.d.ts +7 -0
  99. package/dist/types/types/ContentSection.d.ts +8 -0
  100. package/dist/types/types/GetListingParams.d.ts +8 -0
  101. package/dist/types/types/LatLng.d.ts +4 -0
  102. package/dist/types/types/ListingEntity.d.ts +10 -0
  103. package/dist/types/types/ListingFields.d.ts +20 -0
  104. package/dist/types/types/Listings.d.ts +31 -0
  105. package/dist/types/types/Recruiter.d.ts +9 -0
  106. package/dist/types/types/SimilarListing.d.ts +24 -0
  107. package/dist/types/types/config/Colors.d.ts +8 -0
  108. package/dist/types/types/config/MapConfig.d.ts +29 -0
  109. package/dist/types/types/config/PointsOfInterestConfig.d.ts +13 -0
  110. package/dist/types/types/config/SearchConfig.d.ts +4 -0
  111. package/dist/types/util/filterUtil.d.ts +28 -0
  112. package/dist/types/util/loading.d.ts +3 -0
  113. package/dist/types/util/localStorageUtil.d.ts +3 -0
  114. package/dist/types/util/mapUtil.d.ts +15 -0
  115. package/dist/types/util/sortUtil.d.ts +1 -0
  116. package/dist/types/util/stringUtils.d.ts +1 -0
  117. package/dist/util/filterUtil.js +34 -10
  118. package/dist/util/filterUtil.js.map +1 -1
  119. package/dist/util/localStorageUtil.js +37 -28
  120. package/dist/util/localStorageUtil.js.map +1 -1
  121. package/dist/util/mapUtil.js.map +1 -1
  122. package/package.json +22 -14
  123. package/rollup.config.mjs +23 -19
  124. package/src/apis/{hcApi.js → hcApi.ts} +27 -11
  125. package/src/components/HireControlMap.js +132 -129
  126. package/src/components/modules/accordions/MapAccordionItem.js +32 -74
  127. package/src/components/modules/filter/index.js +89 -89
  128. package/src/components/modules/filter/radio-item.js +0 -1
  129. package/src/components/modules/filter/search.js +93 -92
  130. package/src/components/modules/jobListing/listing-details-container.js +40 -0
  131. package/src/components/modules/jobListing/listing-details.js +209 -99
  132. package/src/components/modules/{maps/list → list}/field-mapper.js +114 -112
  133. package/src/components/modules/{maps/list → list}/header.js +49 -47
  134. package/src/components/modules/list/index.tsx +83 -0
  135. package/src/components/modules/{maps/list → list}/item-expand-card/index.js +24 -22
  136. package/src/components/modules/list/item-list.tsx +198 -0
  137. package/src/components/modules/list/list-item/index.js +70 -0
  138. package/src/components/modules/list/list-item/list-item-container.js +43 -0
  139. package/src/components/modules/{maps/list/list-item/index.js → list/list-item/list-item.js} +129 -135
  140. package/src/components/modules/maps/map-list.js +74 -74
  141. package/src/constants/eventTypes.js +13 -13
  142. package/src/contexts/mapContext.tsx +129 -0
  143. package/src/contexts/mapListContext.tsx +297 -0
  144. package/src/enums/SectionType.ts +9 -0
  145. package/src/services/{configService.js → configService.ts} +16 -16
  146. package/src/services/{googlePlacesNearbyService.js → googlePlacesNearbyService.ts} +11 -2
  147. package/src/services/listingAggregatorService.ts +76 -0
  148. package/src/services/listingEntityService.ts +16 -0
  149. package/src/services/listingService.ts +40 -0
  150. package/src/services/{recruiterService.js → recruiterService.ts} +18 -17
  151. package/src/types/Address.ts +7 -0
  152. package/src/types/ContentSection.ts +9 -0
  153. package/src/types/GetListingParams.ts +8 -0
  154. package/src/types/LatLng.ts +4 -0
  155. package/src/types/ListingEntity.ts +11 -0
  156. package/src/types/ListingFields.ts +20 -0
  157. package/src/types/Listings.ts +32 -0
  158. package/src/types/Recruiter.ts +9 -0
  159. package/src/types/SimilarListing.ts +24 -0
  160. package/src/types/config/Colors.ts +8 -0
  161. package/src/types/config/MapConfig.ts +30 -0
  162. package/src/types/config/PointsOfInterestConfig.ts +13 -0
  163. package/src/types/config/SearchConfig.ts +4 -0
  164. package/src/util/filterUtil.js +50 -6
  165. package/src/util/localStorageUtil.ts +34 -0
  166. package/src/util/mapUtil.js +91 -91
  167. package/tsconfig.json +23 -0
  168. package/dist/components/modules/maps/list/field-mapper.js.map +0 -1
  169. package/dist/components/modules/maps/list/header-item.js.map +0 -1
  170. package/dist/components/modules/maps/list/header.js.map +0 -1
  171. package/dist/components/modules/maps/list/index.js +0 -102
  172. package/dist/components/modules/maps/list/index.js.map +0 -1
  173. package/dist/components/modules/maps/list/item-expand-card/index.js.map +0 -1
  174. package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +0 -1
  175. package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +0 -1
  176. package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +0 -1
  177. package/dist/components/modules/maps/list/list-item/index.js.map +0 -1
  178. package/dist/services/_virtual/_rollupPluginBabelHelpers.js +0 -372
  179. package/dist/services/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  180. package/dist/services/apis/hcApi.js +0 -189
  181. package/dist/services/apis/hcApi.js.map +0 -1
  182. package/dist/services/clientToken.js +0 -7
  183. package/dist/services/clientToken.js.map +0 -1
  184. package/dist/services/styles/index.css +0 -3
  185. package/src/components/modules/maps/list/index.js +0 -112
  186. package/src/contexts/mapContext.js +0 -101
  187. package/src/contexts/mapListContext.js +0 -242
  188. package/src/services/listingAggregatorService.js +0 -50
  189. package/src/services/listingEntityService.js +0 -15
  190. package/src/services/listingService.js +0 -26
  191. package/src/util/localStorageUtil.js +0 -27
  192. /package/dist/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
  193. /package/src/components/modules/{maps/list → list}/header-item.js +0 -0
  194. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-contact-nav.js +0 -0
  195. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-details.js +0 -0
  196. /package/src/components/modules/{maps/list → list}/item-expand-card/recruiter-headshot.js +0 -0
@@ -1,135 +1,129 @@
1
- import React, { forwardRef } from 'react';
2
-
3
- import Grid from '~/components/modules/grid';
4
- import Icon from '~/components/modules/icon';
5
- import FieldMapper from '~/components/modules/maps/list/field-mapper';
6
-
7
- import { useMapList } from '~/contexts/mapListContext';
8
- import { useTrackEvent } from '~/contexts/trackEventContext';
9
-
10
- const ListItem = forwardRef(
11
- (
12
- {
13
- isActive,
14
- bodyClassName,
15
- className,
16
- item,
17
- fieldsShown,
18
- specialFeatures,
19
- onItemSelected,
20
- showMap,
21
- setMobileTab,
22
- favorites,
23
- setFavorites,
24
- ...props
25
- },
26
- ref
27
- ) => {
28
- const { siteConfig } = useMapList();
29
- const { trackEvent, eventTypes } = useTrackEvent();
30
- const mapPinColor = siteConfig.colors.primary.replace("#", "");
31
-
32
- const handleClick = () => {
33
- if (onItemSelected) {
34
- onItemSelected(item);
35
- }
36
- };
37
-
38
- let isFavorite = favorites.includes(item.id);
39
-
40
- const handleFavouriteClick = event => {
41
- event.stopPropagation();
42
- let updatedFavorites;
43
- if (isFavorite) {
44
- updatedFavorites = favorites.filter(fav => fav !== item.id);
45
- } else {
46
- trackEvent(eventTypes.FAVORITE_SELECTED, { jobTitle: item.fields.position, jobCategory: item.fields.category, entityDisplayName: item?.mapDetails?.entityDisplayName });
47
- updatedFavorites = [...favorites, item.id];
48
- }
49
- isFavorite = !isFavorite;
50
- setFavorites(updatedFavorites);
51
- };
52
-
53
- return (
54
- <button
55
- ref={ref}
56
- onClick={handleClick}
57
- className={`
58
- hc-group hc-relative hc-flex md:hc-flex-col hc-w-full md:hc-pl-4 hc-text-left hc-bg-clip-border hc-border hc-border-transparent hc-break-words hc-overflow-hidden hc-cursor-pointer hc-transition-colors hover:hc-bg-uiAccent/5 focus:hover:hc-bg-uiAccent/5
59
- ${isActive ? "hc-bg-uiAccent/5 hc-border-secondary hc-border" : "hc-text-uiText hc-bg-white"}
60
- ${className ?? ""}
61
- `}
62
- {...props}
63
- >
64
- <Grid
65
- columns="hc-grid-flow-col hc-auto-cols-fr"
66
- gap="hc-gap-2"
67
- isAnimated={false}
68
- className={`
69
- hc-block md:hc-grid hc-p-2 hc-ps-4 hc-w-full hc-grow hc-leading-tight hc-text-sm md:hc-text-xs lg:hc-text-sm
70
- ${bodyClassName ?? ""}
71
- `}
72
- >
73
- <Grid.Item className="hc-hidden md:hc-block md:hc-absolute md:hc-left-1.5 hc-top-1.5">
74
- <span className="hc-sr-only">Expand row</span>
75
- <Icon
76
- icon="fluent-emoji-high-contrast:plus"
77
- size="hc-size-2.5"
78
- className={`
79
- hc-opacity-0 hc-text-uiText/60 hc-transition group-hover:hc-opacity-100 group-active:hc-opacity-100
80
- ${isActive ? "hc-opacity-100 hc-rotate-45" : ""}
81
- `}
82
- />
83
-
84
- </Grid.Item>
85
-
86
- <FieldMapper
87
- item={item}
88
- fieldsShown={fieldsShown}
89
- specialFeatures={specialFeatures}
90
- isFavorite={isFavorite}
91
- handleFavouriteClick={handleFavouriteClick}
92
- />
93
- <Grid.Item
94
- key={"favorites"}
95
- className="hc-hidden md:hc-block hc-col-span-1"
96
- >
97
- <Icon
98
- icon={isFavorite ? "mdi:heart" : "mdi:heart-outline"}
99
- size="hc-size-3.5"
100
- iconClasses={isFavorite ? "hc-text-primary" : ""}
101
- title={!isFavorite ? 'Add job to favorites' : 'Remove job from favorites'}
102
- className={`
103
- hc-pr-2 hc-transition-opacity hc-duration-300 hc-cursor-pointer hc-opacity-100"
104
- `}
105
- onClick={e => handleFavouriteClick(e)}
106
- />
107
- </Grid.Item>
108
- </Grid>
109
-
110
- {showMap && (
111
- <div onClick={() => { setMobileTab("mapTab"); handleClick(); }} className="md:hc-hidden hc-w-2/5 sm:hc-w-1/3 hc-p-1.5 hc-my-1 hc-bg-uiAccent/5 hc-border hc-border-uiAccent/10 hc-rounded-sm">
112
- <img
113
- src={`https://maps.googleapis.com/maps/api/staticmap?scale=2&center=${item.mapDetails?.latitude},${item.mapDetails?.longitude}&zoom=10&size=240x180&maptype=roadmap&markers=color:0x${mapPinColor}%7Clabel:•%7C${item.mapDetails?.latitude},${item.mapDetails?.longitude}&key=${process.env.GOOGLE_MAPS_API_KEY}`}
114
- alt={`Map of location for ${item.fields.position}`}
115
- className="hc-w-full hc-h-full hc-object-cover"
116
- />
117
- </div>
118
- )}
119
- </button>
120
- );
121
- }
122
- );
123
-
124
- ListItem.displayName = "ListItem";
125
-
126
- export default React.memo(ListItem, (prevProps, nextProps) => {
127
- return (
128
- (prevProps.isActive === nextProps.isActive ||
129
- prevProps.isActive !== nextProps.isActive) &&
130
- prevProps.bodyClassName === nextProps.bodyClassName &&
131
- prevProps.className === nextProps.className &&
132
- prevProps.fieldsShown === nextProps.fieldsShown &&
133
- prevProps.item.id === nextProps.item.id
134
- );
135
- });
1
+ import React, { forwardRef, useState } from 'react';
2
+ import Grid from '~/components/modules/grid';
3
+ import Icon from '~/components/modules/icon';
4
+ import FieldMapper from '~/components/modules/list/field-mapper';
5
+
6
+ const ListItem = forwardRef(
7
+ (
8
+ {
9
+ isActive,
10
+ bodyClassName,
11
+ className,
12
+ item,
13
+ fieldsShown,
14
+ specialFeatures,
15
+ onItemSelected,
16
+ showMap,
17
+ setMobileTab,
18
+ handleSettingFavorites,
19
+ favorites,
20
+ includeFavorite = false,
21
+ siteConfig,
22
+ trackEvent,
23
+ eventTypes,
24
+ ...props
25
+ },
26
+ ref
27
+ ) => {
28
+ const mapPinColor = !showMap ? null : siteConfig.colors.primary.replace("#", "");
29
+
30
+ const handleClick = () => {
31
+ if (onItemSelected) {
32
+ onItemSelected(item);
33
+ }
34
+ };
35
+ let isFavorite = favorites.includes(item.id);
36
+
37
+ const handleFavouriteClick = (event, item) => {
38
+ if(!includeFavorite)return;
39
+ event.stopPropagation();
40
+ let updatedFavorites;
41
+ if (isFavorite) {
42
+ updatedFavorites = favorites.filter(fav => fav !== item.id);
43
+ } else {
44
+ updatedFavorites = [...favorites, item.id];
45
+ }
46
+ isFavorite = !isFavorite;
47
+ handleSettingFavorites(updatedFavorites);
48
+ };
49
+ return (
50
+ <button
51
+ ref={ref}
52
+ onClick={() => { handleClick(); }}
53
+ className={`
54
+ hc-group hc-relative hc-flex md:hc-flex-col hc-w-full md:hc-pl-4 hc-text-left hc-bg-clip-border hc-border hc-border-transparent hc-break-words hc-overflow-hidden hc-cursor-pointer hc-transition-colors hover:hc-bg-uiAccent/5 focus:hover:hc-bg-uiAccent/5
55
+ ${isActive ? "hc-bg-uiAccent/5 hc-border-secondary hc-border" : "hc-text-uiText hc-bg-white"}
56
+ ${className ?? ""}
57
+ `}
58
+ {...props}
59
+ >
60
+ <Grid
61
+ columns="hc-grid-flow-col hc-auto-cols-fr"
62
+ gap="hc-gap-2"
63
+ isAnimated={false}
64
+ className={`
65
+ hc-block md:hc-grid hc-p-2 hc-ps-4 hc-w-full hc-grow hc-leading-tight hc-text-sm md:hc-text-xs lg:hc-text-sm
66
+ ${bodyClassName ?? ""}
67
+ `}
68
+ >
69
+ <Grid.Item className="hc-hidden md:hc-block md:hc-absolute md:hc-left-1.5 hc-top-1.5">
70
+ <span className="hc-sr-only">Expand row</span>
71
+ <Icon
72
+ icon="fluent-emoji-high-contrast:plus"
73
+ size="hc-size-2.5"
74
+ className={`
75
+ hc-opacity-0 hc-text-uiText/60 hc-transition group-hover:hc-opacity-100 group-active:hc-opacity-100
76
+ ${isActive ? "hc-opacity-100 hc-rotate-45" : ""}
77
+ `}
78
+ />
79
+ </Grid.Item>
80
+ <FieldMapper
81
+ item={item}
82
+ fieldsShown={fieldsShown}
83
+ specialFeatures={specialFeatures}
84
+ isFavorite={isFavorite}
85
+ includeFavorite={includeFavorite}
86
+ handleFavouriteClick={handleFavouriteClick}
87
+ />
88
+ {includeFavorite &&
89
+ <Grid.Item
90
+ key={"favorites"}
91
+ className="hc-hidden md:hc-block hc-col-span-1"
92
+ >
93
+ <Icon
94
+ icon={isFavorite ? "mdi:heart" : "mdi:heart-outline"}
95
+ size="hc-size-3.5"
96
+ iconClasses={isFavorite ? "hc-text-primary" : ""}
97
+ title={!isFavorite ? 'Add job to favorites' : 'Remove job from favorites'}
98
+ className="hc-pr-2 hc-transition-opacity hc-duration-300 hc-cursor-pointer hc-opacity-100"
99
+ onClick={e => {handleFavouriteClick(e, item);}}
100
+ />
101
+ </Grid.Item>
102
+ }
103
+ </Grid>
104
+ {showMap && (
105
+ <div onClick={() => { setMobileTab("mapTab"); handleClick(); }} className="md:hc-hidden hc-w-2/5 sm:hc-w-1/3 hc-p-1.5 hc-my-1 hc-bg-uiAccent/5 hc-border hc-border-uiAccent/10 hc-rounded-sm">
106
+ <img
107
+ src={`https://maps.googleapis.com/maps/api/staticmap?scale=2&center=${item.mapDetails?.latitude},${item.mapDetails?.longitude}&zoom=10&size=240x180&maptype=roadmap&markers=color:0x${mapPinColor}%7Clabel:•%7C${item.mapDetails?.latitude},${item.mapDetails?.longitude}&key=${process.env.GOOGLE_MAPS_API_KEY}`}
108
+ alt={`Map of location for ${item.fields.position}`}
109
+ className="hc-w-full hc-h-full hc-object-cover"
110
+ />
111
+ </div>
112
+ )}
113
+ </button>
114
+ );
115
+ }
116
+ );
117
+
118
+ ListItem.displayName = "ListItem";
119
+
120
+ export default React.memo(ListItem, (prevProps, nextProps) => {
121
+ return (
122
+ prevProps.isActive === nextProps.isActive &&
123
+ prevProps.favorites === nextProps.favorites &&
124
+ prevProps.item.id === nextProps.item.id &&
125
+ prevProps.fieldsShown === nextProps.fieldsShown &&
126
+ prevProps.bodyClassName === nextProps.bodyClassName &&
127
+ prevProps.className === nextProps.className
128
+ );
129
+ });
@@ -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;
@@ -1,13 +1,13 @@
1
- export const eventTypes = {
2
- FILTER_APPLIED: "filter_applied",
3
- MAP_MARKER_CLICKED: "map_marker_clicked",
4
- JOB_LISTING_SELECTED: "job_listing_selected",
5
- APPLY_NOW_CLICKED: "apply_now_clicked",
6
- VIEW_DETAILS_CLICKED: "view_details_clicked",
7
- COMMUTE_ORIGIN_ADDED: "commute_origin_added",
8
- POI_APPLIED: "point_of_interest_applied",
9
- VIEW_JOBS_AT_Location: "view_jobs_at_location_clicked",
10
- FAVORITE_SELECTED: "favorite_job_selected",
11
- LIST_SORTED: "jobs_list_sorted",
12
- FILTERS_RESET: "filters_reset_button_clicked"
13
- };
1
+ export const eventTypes = {
2
+ FILTER_APPLIED: "filter_applied",
3
+ MAP_MARKER_CLICKED: "map_marker_clicked",
4
+ JOB_LISTING_SELECTED: "job_listing_selected",
5
+ APPLY_NOW_CLICKED: "apply_now_clicked",
6
+ VIEW_DETAILS_CLICKED: "view_details_clicked",
7
+ COMMUTE_ORIGIN_ADDED: "commute_origin_added",
8
+ POI_APPLIED: "point_of_interest_applied",
9
+ VIEW_JOBS_AT_Location: "view_jobs_at_location_clicked",
10
+ FAVORITE_SELECTED: "favorite_job_selected",
11
+ LIST_SORTED: "jobs_list_sorted",
12
+ FILTERS_RESET: "filter_reset_button_clicked"
13
+ };
@@ -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
+ };