@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 +1 @@
1
- {"version":3,"file":"mapContext.js","sources":["../../src/contexts/mapContext.js"],"sourcesContent":["import React, { createContext, useState, useContext, useEffect, useRef } from 'react';\r\nimport { getStorageObject, setStorageObject } from '~/util/localStorageUtil';\r\n\r\nconst MapContext = createContext();\r\n\r\nexport const useMap = () => {\r\n\tconst context = useContext(MapContext);\r\n\tif (!context) {\r\n\t\tthrow new Error(\"useMap must be used within a MapProvider\");\r\n\t}\r\n\treturn context;\r\n};\r\n\r\nexport const MapProvider = ({ children, resetFilters }) => {\r\n\tconst [selectedListItem, setSelectedListItem] = useState(getStorageObject('selectedListItem'));\r\n\tconst [location, setLocation] = useState(getStorageObject('location'));\r\n\tconst [center, setCenter] = useState(getStorageObject(\"center\", { lat: 39.8283, lng: -98.5795 }));\r\n\tconst [zoom, setZoom] = useState(getStorageObject(\"zoom\", 10));\r\n\tconst [selectedPlaces, setSelectedPlaces] = useState([]);\r\n\tconst [mapInteracted, setMapInteracted] = useState(false);\r\n\tconst [firstLoadListItem] = useState(getStorageObject('selectedListItem') ?? { id: \"defaultId\" });\r\n\tconst userSetZoom = useRef(true);\r\n\r\n\tuseEffect(() => {\r\n\t\tsetStorageObject(\"selectedListItem\", selectedListItem);\r\n\t}, [selectedListItem]);\r\n\r\n\tuseEffect(() => {\r\n\t\tlocalStorage.setItem(\"zoom\", zoom);\r\n\t}, [zoom]);\r\n\r\n\tuseEffect(() => {\r\n\t\tif (location == null) {\r\n\t\t\tlocalStorage.removeItem(\"location\");\r\n\t\t} else {\r\n\t\t\tsetStorageObject(\"location\", location);\r\n\t\t}\r\n\t}, [location]);\r\n\r\n\tuseEffect(() => {\r\n\t\tsetStorageObject(\"center\", center);\r\n\t}, [center]);\r\n\r\n\tconst selectItem = (item, itemLocation, zoom, center) => {\r\n\t\tsetSelectedListItem(item);\r\n\t\tif (mapInteracted === false && itemLocation != null) {\r\n\t\t\tsetLocation(itemLocation);\r\n\t\t}\r\n\t\tif (mapInteracted === false || itemLocation != null) {\r\n\t\t\tsetLocation(itemLocation);\r\n\t\t\tsetCenter(center);\r\n\t\t}\r\n\t\tif (mapInteracted === false) {\r\n\t\t\tsetZoom(zoom);\r\n\r\n\t\t}\r\n\t};\r\n\r\n\tconst filterReset = () => {\r\n\t\tsetSelectedPlaces({});\r\n\t\tsetSelectedListItem(null);\r\n\t\tsetLocation(null);\r\n\t\tsetZoom(8);\r\n\t\tsetMapInteracted(false);\r\n\t};\r\n\r\n\tif (resetFilters === true) {\r\n\t\tfilterReset();\r\n\t}\r\n\tconst selectLocationEntity = location => {\r\n\r\n\t\tlocalStorage.removeItem(\"selectedListItem\");\r\n\t\tsetTimeout(() => setLocation(location), 200);\r\n\t\tsetSelectedListItem(null);\r\n\t};\r\n\r\n\treturn (\r\n\t\t<MapContext.Provider\r\n\t\t\tvalue={{\r\n\t\t\t\tselectedListItem,\r\n\t\t\t\tsetSelectedListItem,\r\n\t\t\t\tlocation,\r\n\t\t\t\tcenter,\r\n\t\t\t\tzoom,\r\n\t\t\t\tsetZoom,\r\n\t\t\t\tselectItem,\r\n\t\t\t\tsetSelectedPlaces,\r\n\t\t\t\tselectedPlaces,\r\n\t\t\t\tselectLocationEntity,\r\n\t\t\t\tsetLocation,\r\n\t\t\t\tsetMapInteracted,\r\n\t\t\t\tmapInteracted,\r\n\t\t\t\tuserSetZoom,\r\n\t\t\t\tfirstLoadListItem,\r\n\t\t\t\tfilterReset\r\n\t\t\t}}\r\n\t\t>\r\n\t\t\t{children}\r\n\t\t</MapContext.Provider>\r\n\t);\r\n};\r\n"],"names":["MapContext","createContext","useMap","context","useContext","Error","MapProvider","_ref","_getStorageObject","children","resetFilters","_useState","useState","getStorageObject","_useState2","_slicedToArray","selectedListItem","setSelectedListItem","_useState3","_useState4","location","setLocation","_useState5","lat","lng","_useState6","center","setCenter","_useState7","_useState8","zoom","setZoom","_useState9","_useState10","selectedPlaces","setSelectedPlaces","_useState11","_useState12","mapInteracted","setMapInteracted","_useState13","id","_useState14","firstLoadListItem","userSetZoom","useRef","useEffect","setStorageObject","localStorage","setItem","removeItem","selectItem","item","itemLocation","filterReset","selectLocationEntity","setTimeout","React","createElement","Provider","value"],"mappings":";;;;AAGA,IAAMA,UAAU,gBAAGC,aAAa,EAAE,CAAA;IAErBC,MAAM,GAAG,SAATA,MAAMA,GAAS;AAC3B,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACJ,UAAU,CAAC,CAAA;EACtC,IAAI,CAACG,OAAO,EAAE;AACb,IAAA,MAAM,IAAIE,KAAK,CAAC,0CAA0C,CAAC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ACvB,CAAA;EAED,IAAI7B,YAAY,KAAK,IAAI,EAAE;AAC1B4C,IAAAA,WAAW,EAAE,CAAA;AACd,GAAA;AACA,EAAA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAGnC,QAAQ,EAAI;AAExC4B,IAAAA,YAAY,CAACE,UAAU,CAAC,kBAAkB,CAAC,CAAA;AAC3CM,IAAAA,UAAU,CAAC,YAAA;MAAA,OAAMnC,WAAW,CAACD,QAAQ,CAAC,CAAA;AAAA,KAAA,EAAE,GAAG,CAAC,CAAA;IAC5CH,mBAAmB,CAAC,IAAI,CAAC,CAAA;GACzB,CAAA;AAED,EAAA,oBACCwC,KAAA,CAAAC,aAAA,CAAC1D,UAAU,CAAC2D,QAAQ,EAAA;AACnBC,IAAAA,KAAK,EAAE;AACN5C,MAAAA,gBAAgB,EAAhBA,gBAAgB;AAChBC,MAAAA,mBAAmB,EAAnBA,mBAAmB;AACnBG,MAAAA,QAAQ,EAARA,QAAQ;AACRM,MAAAA,MAAM,EAANA,MAAM;AACNI,MAAAA,IAAI,EAAJA,IAAI;AACJC,MAAAA,OAAO,EAAPA,OAAO;AACPoB,MAAAA,UAAU,EAAVA,UAAU;AACVhB,MAAAA,iBAAiB,EAAjBA,iBAAiB;AACjBD,MAAAA,cAAc,EAAdA,cAAc;AACdqB,MAAAA,oBAAoB,EAApBA,oBAAoB;AACpBlC,MAAAA,WAAW,EAAXA,WAAW;AACXkB,MAAAA,gBAAgB,EAAhBA,gBAAgB;AAChBD,MAAAA,aAAa,EAAbA,aAAa;AACbM,MAAAA,WAAW,EAAXA,WAAW;AACXD,MAAAA,iBAAiB,EAAjBA,iBAAiB;AACjBW,MAAAA,WAAW,EAAXA,WAAAA;AACD,KAAA;AAAE,GAAA,EAED7C,QACmB,CAAC,CAAA;AAExB;;;;"}
1
+ {"version":3,"file":"mapContext.js","sources":["../../src/contexts/mapContext.tsx"],"sourcesContent":["import React, { createContext, useState, useContext, useEffect, useRef, ReactNode } from 'react';\nimport { getStorageObject, setStorageObject } from '~/util/localStorageUtil';\nimport { Listing } from '~/types/Listings';\nimport { LatLng } from '~/types/LatLng';\ninterface IMapContext {\n selectedListItem: Listing | null;\n setSelectedListItem: (item: Listing | null) => void;\n location: any | null;\n setLocation: (location: LatLng | null) => void;\n center: LatLng;\n setCenter: (center: LatLng) => void;\n zoom: number;\n setZoom: (zoom: number) => void;\n selectedPlaces: string[];\n setSelectedPlaces: (places: string[]) => void;\n mapInteracted: boolean;\n setMapInteracted: (interacted: boolean) => void;\n userSetZoom: React.MutableRefObject<boolean>;\n firstLoadListItem: any;\n selectItem: (item: Listing, itemLocation: LatLng | null, zoom: number, center: LatLng) => void;\n filterReset: () => void;\n selectLocationEntity: (location: LatLng) => void;\n}\n\nconst MapContext = createContext<IMapContext | undefined>(undefined);\n\nexport const useMap = () => {\n\tconst context = useContext(MapContext);\n\tif (!context) {\n\t\tthrow new Error(\"useMap must be used within a MapProvider\");\n\t}\n\treturn context;\n};\n\ninterface MapProviderProps {\n children: ReactNode;\n resetFilters: boolean;\n}\n\nexport const MapProvider: React.FC<MapProviderProps> = ({ children, resetFilters }) => {\n\tconst [selectedListItem, setSelectedListItem] = useState<Listing | null>(getStorageObject('selectedListItem'));\n\tconst [location, setLocation] = useState<any>(getStorageObject('location'));\n\tconst [center, setCenter] = useState<LatLng>(getStorageObject(\"center\", { lat: 39.8283, lng: -98.5795 }) || { lat: 39.8283, lng: -98.5795 });\n\tconst [zoom, setZoom] = useState<number>(getStorageObject(\"zoom\", 10) || 10);\n\tconst [selectedPlaces, setSelectedPlaces] = useState<string[]>([]);\n\tconst [mapInteracted, setMapInteracted] = useState<boolean>(false);\n\tconst [firstLoadListItem] = useState<any>(getStorageObject('selectedListItem', { id: \"defaultId\" }));\n\tconst userSetZoom = useRef<boolean>(true);\n\n\tuseEffect(() => {\n\t\tsetStorageObject(\"selectedListItem\", selectedListItem);\n\t}, [selectedListItem]);\n\n\tuseEffect(() => {\n\t\tlocalStorage.setItem(\"zoom\", zoom.toString());\n\t}, [zoom]);\n\n\tuseEffect(() => {\n\t\tif (location == null) {\n\t\t\tlocalStorage.removeItem(\"location\");\n\t\t} else {\n\t\t\tsetStorageObject(\"location\", location);\n\t\t}\n\t}, [location]);\n\n\tuseEffect(() => {\n\t\tsetStorageObject(\"center\", center);\n\t}, [center]);\n\n\tconst selectItem = (item: Listing, itemLocation: LatLng | null, zoom: number, center: LatLng) => {\n\t\tsetSelectedListItem(item);\n\t\tif (mapInteracted === false && itemLocation != null) {\n\t\t\tsetLocation(itemLocation);\n\t\t}\n\t\tif (mapInteracted === false || itemLocation != null) {\n\t\t\tsetLocation(itemLocation);\n\t\t\tsetCenter(center);\n\t\t}\n\t\tif (mapInteracted === false) {\n\t\t\tsetZoom(zoom);\n\t\t}\n\t};\n\n\tconst filterReset = () => {\n\t\tsetSelectedPlaces([]);\n\t\tsetSelectedListItem(null);\n\t\tsetLocation(null);\n\t\tsetZoom(8);\n\t\tsetMapInteracted(false);\n\t};\n\n\tuseEffect(() => {\n\t\tif (resetFilters === true) {\n\t\t\tfilterReset();\n\t\t}\n\t}, [resetFilters]);\n\n\tconst selectLocationEntity = (location: LatLng) => {\n\t\tlocalStorage.removeItem(\"selectedListItem\");\n\t\tsetTimeout(() => setLocation(location), 200);\n\t\tsetSelectedListItem(null);\n\t};\n\n\treturn (\n\t\t<MapContext.Provider\n\t\t\tvalue={{\n\t\t\t\tselectedListItem,\n\t\t\t\tsetSelectedListItem,\n\t\t\t\tlocation,\n\t\t\t\tcenter,\n\t\t\t\tsetCenter,\n\t\t\t\tzoom,\n\t\t\t\tsetZoom,\n\t\t\t\tselectItem,\n\t\t\t\tsetSelectedPlaces,\n\t\t\t\tselectedPlaces,\n\t\t\t\tselectLocationEntity,\n\t\t\t\tsetLocation,\n\t\t\t\tsetMapInteracted,\n\t\t\t\tmapInteracted,\n\t\t\t\tuserSetZoom,\n\t\t\t\tfirstLoadListItem,\n\t\t\t\tfilterReset\n\t\t\t}}\n\t\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EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;AACd,SAAA;AACF,KAAC,CAAC;IAEF,MAAM,WAAW,GAAG,MAAK;QACxB,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACtB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC1B,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,CAAC,CAAC,CAAC,CAAC;QACX,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACzB,KAAC,CAAC;IAEF,SAAS,CAAC,MAAK;QACd,IAAI,YAAY,KAAK,IAAI,EAAE;AAC1B,YAAA,WAAW,EAAE,CAAC;AACd,SAAA;AACF,KAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AAEnB,IAAA,MAAM,oBAAoB,GAAG,CAAC,QAAgB,KAAI;AACjD,QAAA,YAAY,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAC5C,UAAU,CAAC,MAAM,WAAW,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;QAC7C,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAC3B,KAAC,CAAC;AAEF,IAAA,QACC,KAAC,CAAA,aAAA,CAAA,UAAU,CAAC,QAAQ,EAAA,EACnB,KAAK,EAAE;YACN,gBAAgB;YAChB,mBAAmB;YACnB,QAAQ;YACR,MAAM;YACN,SAAS;YACT,IAAI;YACJ,OAAO;YACP,UAAU;YACV,iBAAiB;YACjB,cAAc;YACd,oBAAoB;YACpB,WAAW;YACX,gBAAgB;YAChB,aAAa;YACb,WAAW;YACX,iBAAiB;YACjB,WAAW;SACX,EAEA,EAAA,QAAQ,CACY,EACrB;AACH;;;;"}
@@ -1,298 +1,189 @@
1
- import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime, toConsumableArray as _toConsumableArray } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import React, { useContext, useState, useEffect, createContext } from 'react';
1
+ import React, { createContext, useState, useEffect, useContext } from 'react';
3
2
  import { applyFilters, generateFilterOptions, filterListingsByLocation } from '../util/filterUtil.js';
4
3
  import { getStorageObject, setStorageObject } from '../util/localStorageUtil.js';
5
4
  import { getListingEntities } from '../services/listingEntityService.js';
6
5
  import fetchListings from '../services/listingAggregatorService.js';
7
6
 
8
- var MapListContext = /*#__PURE__*/createContext();
9
- var useMapList = function useMapList() {
10
- return useContext(MapListContext);
11
- };
12
- var getQuery = function getQuery() {
13
- var query;
14
- //if (!hasQueryInUrl(location)) {
15
- query = typeof window !== 'undefined' ? localStorage.getItem('query') : '';
16
- // }
17
- //else {
18
- // query = filtersFromURL(location).query;
19
- // }
20
- return query;
21
- };
22
- var MapListProvider = function MapListProvider(_ref) {
23
- var children = _ref.children,
24
- siteConfig = _ref.siteConfig,
25
- resetFilters = _ref.resetFilters,
26
- navigateToDetails = _ref.navigateToDetails,
27
- navigateToEasyApply = _ref.navigateToEasyApply,
28
- Link = _ref.Link,
29
- linkFormat = _ref.linkFormat,
30
- trackEvent = _ref.trackEvent;
31
- // const location = useLocation();
32
- // const navigate = useNavigate();
33
- var _useState = useState(getStorageObject("listings", [])),
34
- _useState2 = _slicedToArray(_useState, 2),
35
- allListings = _useState2[0],
36
- setAllListings = _useState2[1];
37
- var _useState3 = useState([]),
38
- _useState4 = _slicedToArray(_useState3, 2),
39
- filteredListings = _useState4[0],
40
- setFilteredListings = _useState4[1];
41
- var _useState5 = useState(false),
42
- _useState6 = _slicedToArray(_useState5, 2),
43
- loading = _useState6[0],
44
- setLoading = _useState6[1];
45
- var _useState7 = useState(getStorageObject('mapItems', [])),
46
- _useState8 = _slicedToArray(_useState7, 2),
47
- mapItems = _useState8[0],
48
- setMapItems = _useState8[1];
49
- var _useState9 = useState(function () {
50
- return resetFilters ? null : getQuery();
51
- }),
52
- _useState10 = _slicedToArray(_useState9, 2),
53
- query = _useState10[0],
54
- setQuery = _useState10[1];
55
- var _useState11 = useState(getStorageObject('sortSetting', null)),
56
- _useState12 = _slicedToArray(_useState11, 2),
57
- sortSetting = _useState12[0],
58
- setSortSetting = _useState12[1];
59
- var _useState13 = useState(getStorageObject("listingEntities", null)),
60
- _useState14 = _slicedToArray(_useState13, 2),
61
- listingEntities = _useState14[0],
62
- setListingEntities = _useState14[1];
63
- var _useState15 = useState(true),
64
- _useState16 = _slicedToArray(_useState15, 2),
65
- firstLoad = _useState16[0],
66
- setFirstLoad = _useState16[1];
67
- var _useState17 = useState(getStorageObject('commuteLocation')),
68
- _useState18 = _slicedToArray(_useState17, 2),
69
- commuteLocation = _useState18[0],
70
- setCommuteLocation = _useState18[1];
71
- var _useState19 = useState(function () {
72
- return resetFilters ? {} : getStorageObject('selectedFilters', {});
73
- }),
74
- _useState20 = _slicedToArray(_useState19, 2),
75
- selectedFilters = _useState20[0],
76
- setSelectedFilters = _useState20[1]; //hasFiltersInURL(location) ? filtersFromURL(location).filters : getStorageObject('selectedFilters', {}));
77
- var _useState21 = useState(),
78
- _useState22 = _slicedToArray(_useState21, 2),
79
- filterOptions = _useState22[0],
80
- setFilterOptions = _useState22[1];
81
- var _useState23 = useState(getStorageObject("recruiters", {})),
82
- _useState24 = _slicedToArray(_useState23, 2),
83
- recruiters = _useState24[0],
84
- setRecruiters = _useState24[1];
85
- var _useState25 = useState(false),
86
- _useState26 = _slicedToArray(_useState25, 2),
87
- filterDialogIsOpen = _useState26[0],
88
- setFilterDialogIsOpen = _useState26[1];
89
- var _useState27 = useState("listTab"),
90
- _useState28 = _slicedToArray(_useState27, 2),
91
- mobileTab = _useState28[0],
92
- setMobileTab = _useState28[1];
93
- var _useState29 = useState([]),
94
- _useState30 = _slicedToArray(_useState29, 2),
95
- favorites = _useState30[0],
96
- setFavorites = _useState30[1];
97
- var _useState31 = useState(false),
98
- _useState32 = _slicedToArray(_useState31, 2),
99
- filterByFavorites = _useState32[0],
100
- setFilterByFavorites = _useState32[1];
101
- var setNewFilteredListings = function setNewFilteredListings(filteredListings) {
102
- setFilteredListings(filteredListings);
103
- };
104
- useEffect(function () {
105
- if (!sortSetting) return;
106
- localStorage.setItem('sortSetting', JSON.stringify(sortSetting));
107
- setNewFilteredListings(filteredListings);
108
- }, [sortSetting]);
109
- useEffect(function () {
110
- var loadedFavorites = JSON.parse(localStorage.getItem('favorites')) || [];
111
- setFavorites(loadedFavorites);
112
- }, []);
113
- useEffect(function () {
114
- setStorageObject("commuteLocation", commuteLocation);
115
- }, [commuteLocation]);
116
- useEffect(function () {
117
- if (commuteLocation === null || commuteLocation === '') return;
118
- function fetchEntities() {
119
- return _fetchEntities.apply(this, arguments);
120
- }
121
- function _fetchEntities() {
122
- _fetchEntities = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
123
- var distinctEntityIds, fetchedEntities, newFilteredListings, i, j;
124
- return _regeneratorRuntime().wrap(function _callee$(_context) {
125
- while (1) switch (_context.prev = _context.next) {
126
- case 0:
127
- distinctEntityIds = _toConsumableArray(new Set(allListings.map(function (listing) {
128
- return listing.entityId;
129
- })));
130
- _context.prev = 1;
131
- _context.next = 4;
132
- return getListingEntities(distinctEntityIds, "".concat(commuteLocation.lat, ", ").concat(commuteLocation.lng));
133
- case 4:
134
- fetchedEntities = _context.sent;
135
- setListingEntities(fetchedEntities);
136
- newFilteredListings = filteredListings;
137
- for (i = 0; i < allListings.length; i++) {
138
- if (newFilteredListings[i].entityId != -1) {
139
- newFilteredListings[i].fields.travelTime = fetchedEntities[newFilteredListings[i].entityId].travelTime;
140
- }
141
- }
142
- for (j = 0; j < newFilteredListings.length; j++) {
143
- if (newFilteredListings[j].entityId != -1) {
144
- newFilteredListings[j].fields.travelTime = fetchedEntities[newFilteredListings[j].entityId].travelTime;
145
- }
146
- }
147
- setNewFilteredListings(newFilteredListings);
148
- _context.next = 15;
149
- break;
150
- case 12:
151
- _context.prev = 12;
152
- _context.t0 = _context["catch"](1);
153
- console.error("Failed to fetch listing entities:", _context.t0);
154
- case 15:
155
- case "end":
156
- return _context.stop();
157
- }
158
- }, _callee, null, [[1, 12]]);
159
- }));
160
- return _fetchEntities.apply(this, arguments);
161
- }
162
- fetchEntities();
163
- }, [commuteLocation, allListings, siteConfig.companyId]);
164
- useEffect(function () {
165
- var handleFetchListings = /*#__PURE__*/function () {
166
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
167
- var _yield$fetchListings, listingsResult, fetchedRecruiters, fetchedEntities, distinctItems;
168
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
169
- while (1) switch (_context2.prev = _context2.next) {
170
- case 0:
171
- if (!getStorageObject('listings', []).length > 0) {
172
- setLoading(true);
173
- }
174
- _context2.prev = 1;
175
- _context2.next = 4;
176
- return fetchListings(query, siteConfig, commuteLocation);
177
- case 4:
178
- _yield$fetchListings = _context2.sent;
179
- listingsResult = _yield$fetchListings.listingsResult;
180
- fetchedRecruiters = _yield$fetchListings.fetchedRecruiters;
181
- fetchedEntities = _yield$fetchListings.fetchedEntities;
182
- distinctItems = _yield$fetchListings.distinctItems;
183
- setAllListings(listingsResult);
184
- setRecruiters(fetchedRecruiters);
185
- setListingEntities(fetchedEntities);
186
- setMapItems(distinctItems);
187
- setStorageObject("mapItems", distinctItems);
188
- setStorageObject("listingEntities", fetchedEntities);
189
- setStorageObject("recruiters", fetchedRecruiters);
190
- setStorageObject("listings", listingsResult);
191
- _context2.next = 22;
192
- break;
193
- case 19:
194
- _context2.prev = 19;
195
- _context2.t0 = _context2["catch"](1);
196
- console.log(_context2.t0);
197
- case 22:
198
- setLoading(false);
199
- case 23:
200
- case "end":
201
- return _context2.stop();
202
- }
203
- }, _callee2, null, [[1, 19]]);
204
- }));
205
- return function handleFetchListings() {
206
- return _ref2.apply(this, arguments);
207
- };
208
- }();
209
- handleFetchListings();
210
- }, [query, siteConfig]);
211
- useEffect(function () {
212
- var processListings = function processListings() {
213
- var _applyFilters = applyFilters(allListings, selectedFilters, query, listingEntities, favorites, siteConfig),
214
- filteredListings = _applyFilters.filteredListings,
215
- mapItems = _applyFilters.mapItems;
216
- if (filterByFavorites) {
217
- filteredListings = filteredListings.filter(function (x) {
218
- return favorites.includes(x.id);
219
- });
220
- }
221
- setNewFilteredListings(filteredListings);
222
- // if (firstLoad && hasFiltersInURL(location)) {
223
- // const { filters } = filtersFromURL(location);
224
- // setSelectedFilters(filters);
225
- // }
226
- if (firstLoad && selectedFilters) ; else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
227
- localStorage.removeItem('selectedFilters');
228
- //updateURLWithFilters(selectedFilters,location, navigate, query);
229
- } else if (!firstLoad) {
230
- setStorageObject('selectedFilters', selectedFilters);
231
- //updateURLWithFilters(selectedFilters,location, navigate, query);
232
- }
233
- query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
234
- setMapItems(mapItems);
235
- if (selectedFilters) {
236
- var keys = Object.keys(selectedFilters);
237
- var lastKey = keys[keys.length - 1];
238
- var options = generateFilterOptions(firstLoad ? allListings : filteredListings, allListings, siteConfig, filterOptions, lastKey, favorites);
239
- if (options) {
240
- setFilterOptions(options);
241
- if (firstLoad) setFirstLoad(false);
242
- }
243
- }
244
- };
245
- processListings();
246
- }, [selectedFilters, query, listingEntities, filterByFavorites, favorites]);
247
- var handleFilterListingsByLocation = function handleFilterListingsByLocation(selectedLocation) {
248
- var _filterListingsByLoca = filterListingsByLocation(allListings, selectedLocation, listingEntities),
249
- filteredListings = _filterListingsByLoca.filteredListings;
250
- setNewFilteredListings(filteredListings);
251
- //setMapItems(mapItems);
252
- };
253
- var handleSettingFavorites = function handleSettingFavorites(newFavorites) {
254
- if (newFavorites == null) {
255
- localStorage.removeItem('favorites');
256
- } else {
257
- setFavorites(newFavorites);
258
- localStorage.setItem('favorites', JSON.stringify(newFavorites));
259
- }
260
- };
261
- return /*#__PURE__*/React.createElement(MapListContext.Provider, {
262
- value: {
263
- loading: loading,
264
- allListings: allListings,
265
- filteredListings: filteredListings,
266
- mapItems: mapItems,
267
- query: query,
268
- setNewFilteredListings: setNewFilteredListings,
269
- setQuery: setQuery,
270
- listingEntities: listingEntities,
271
- selectedFilters: selectedFilters,
272
- setSelectedFilters: setSelectedFilters,
273
- filterOptions: filterOptions,
274
- recruiters: recruiters,
275
- handleFilterListingsByLocation: handleFilterListingsByLocation,
276
- filterDialogIsOpen: filterDialogIsOpen,
277
- setFilterDialogIsOpen: setFilterDialogIsOpen,
278
- setMobileTab: setMobileTab,
279
- mobileTab: mobileTab,
280
- siteConfig: siteConfig,
281
- favorites: favorites,
282
- handleSettingFavorites: handleSettingFavorites,
283
- setFilterByFavorites: setFilterByFavorites,
284
- filterByFavorites: filterByFavorites,
285
- commuteLocation: commuteLocation,
286
- setCommuteLocation: setCommuteLocation,
287
- navigateToDetails: navigateToDetails,
288
- navigateToEasyApply: navigateToEasyApply,
289
- Link: Link,
290
- linkFormat: linkFormat,
291
- sortSetting: sortSetting,
292
- setSortSetting: setSortSetting,
293
- trackEvent: trackEvent
294
- }
295
- }, children);
7
+ const MapListContext = createContext(undefined);
8
+ const useMapList = () => {
9
+ const context = useContext(MapListContext);
10
+ if (!context) {
11
+ throw new Error('useMapList must be used within a MapListProvider');
12
+ }
13
+ return context;
14
+ };
15
+ const getQuery = () => {
16
+ let query = null;
17
+ if (typeof window !== 'undefined') {
18
+ query = localStorage.getItem('query');
19
+ }
20
+ return query;
21
+ };
22
+ const MapListProvider = ({ children, siteConfig, resetFilters, navigateToDetails, navigateToEasyApply, Link, linkFormat, trackEvent, listings = [] }) => {
23
+ const [allListings, setAllListings] = useState(getStorageObject("listings", listings) || []);
24
+ const [filteredListings, setFilteredListings] = useState([]);
25
+ const [loading, setLoading] = useState(false);
26
+ const [mapItems, setMapItems] = useState(getStorageObject('mapItems', []) || []);
27
+ const [query, setQuery] = useState(() => resetFilters ? null : getQuery());
28
+ const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', { field: 'position', type: 'asc' }) || { field: 'position', type: 'asc' });
29
+ const [listingEntities, setListingEntities] = useState(getStorageObject("listingEntities", null));
30
+ const [firstLoad, setFirstLoad] = useState(true);
31
+ const [commuteLocation, setCommuteLocation] = useState(getStorageObject('commuteLocation'));
32
+ const [selectedFilters, setSelectedFilters] = useState(() => resetFilters ? {} : getStorageObject('selectedFilters', {}) || {});
33
+ const [filterOptions, setFilterOptions] = useState();
34
+ const [recruiters, setRecruiters] = useState(getStorageObject("recruiters", {}) || {});
35
+ const [filterDialogIsOpen, setFilterDialogIsOpen] = useState(false);
36
+ const [mobileTab, setMobileTab] = useState("listTab");
37
+ const [favorites, setFavorites] = useState([]);
38
+ const [filterByFavorites, setFilterByFavorites] = useState(false);
39
+ const setNewFilteredListings = (filteredListings) => {
40
+ setFilteredListings(filteredListings);
41
+ };
42
+ useEffect(() => {
43
+ if (!sortSetting)
44
+ return;
45
+ localStorage.setItem('sortSetting', JSON.stringify(sortSetting));
46
+ setNewFilteredListings(filteredListings);
47
+ }, [sortSetting]);
48
+ useEffect(() => {
49
+ const loadedFavorites = JSON.parse(localStorage.getItem('favorites') || '[]');
50
+ setFavorites(loadedFavorites);
51
+ }, []);
52
+ useEffect(() => {
53
+ setStorageObject("commuteLocation", commuteLocation);
54
+ }, [commuteLocation]);
55
+ useEffect(() => {
56
+ if (!commuteLocation)
57
+ return;
58
+ async function fetchEntities() {
59
+ const distinctEntityIds = [
60
+ ...new Set(allListings.map(listing => listing.entityId ?? -1))
61
+ ];
62
+ try {
63
+ const fetchedEntities = await getListingEntities(distinctEntityIds, `${commuteLocation.lat}, ${commuteLocation.lng}`);
64
+ setListingEntities(fetchedEntities);
65
+ const newFilteredListings = [...filteredListings] ?? [];
66
+ for (let i = 0; i < allListings.length; i++) {
67
+ const listing = newFilteredListings[i];
68
+ if (listing &&
69
+ listing.fields &&
70
+ listing.entityId !== undefined &&
71
+ listing.entityId !== -1) {
72
+ const entityId = listing.entityId;
73
+ const travelTime = fetchedEntities[entityId]?.travelTime;
74
+ if (travelTime !== undefined && listing.fields) {
75
+ listing.fields.travelTime = travelTime;
76
+ }
77
+ }
78
+ }
79
+ setNewFilteredListings(newFilteredListings);
80
+ }
81
+ catch (error) {
82
+ console.error("Failed to fetch listing entities:", error);
83
+ }
84
+ }
85
+ fetchEntities();
86
+ }, [commuteLocation, allListings, siteConfig.companyId]);
87
+ useEffect(() => {
88
+ const handleFetchListings = async () => {
89
+ if (!getStorageObject('listings') ?? [].length) {
90
+ setLoading(true);
91
+ }
92
+ try {
93
+ const { listingsResult, fetchedRecruiters, fetchedEntities, distinctItems } = await fetchListings(query ?? '', siteConfig, commuteLocation);
94
+ setAllListings(listingsResult);
95
+ setRecruiters(fetchedRecruiters);
96
+ setListingEntities(fetchedEntities);
97
+ setMapItems(distinctItems);
98
+ setStorageObject("mapItems", distinctItems);
99
+ setStorageObject("listingEntities", fetchedEntities);
100
+ setStorageObject("recruiters", fetchedRecruiters);
101
+ setStorageObject("listings", listingsResult);
102
+ }
103
+ catch (error) {
104
+ console.log(error);
105
+ }
106
+ setLoading(false);
107
+ };
108
+ handleFetchListings();
109
+ }, [query, siteConfig]);
110
+ useEffect(() => {
111
+ const processListings = () => {
112
+ let filteredListings;
113
+ const { mapItems, filteredListings: tempFilteredListings } = applyFilters(allListings, selectedFilters, query, listingEntities, favorites, siteConfig);
114
+ filteredListings = tempFilteredListings;
115
+ if (filterByFavorites) {
116
+ filteredListings = filteredListings.filter((x) => favorites.includes(x.id));
117
+ }
118
+ setNewFilteredListings(filteredListings);
119
+ if (firstLoad && selectedFilters) ;
120
+ else if (Object.keys(selectedFilters).length === 0 && !firstLoad) {
121
+ localStorage.removeItem('selectedFilters');
122
+ }
123
+ else if (!firstLoad) {
124
+ setStorageObject('selectedFilters', selectedFilters);
125
+ }
126
+ query != null ? localStorage.setItem('query', query) : localStorage.removeItem('query');
127
+ setMapItems(mapItems);
128
+ if (selectedFilters) {
129
+ const keys = Object.keys(selectedFilters);
130
+ const lastKey = keys[keys.length - 1];
131
+ const options = generateFilterOptions(firstLoad ? allListings : filteredListings, allListings, siteConfig, filterOptions, lastKey, favorites);
132
+ if (options) {
133
+ setFilterOptions(options);
134
+ if (firstLoad)
135
+ setFirstLoad(false);
136
+ }
137
+ }
138
+ };
139
+ processListings();
140
+ }, [selectedFilters, query, listingEntities, filterByFavorites, favorites]);
141
+ const handleFilterListingsByLocation = (selectedLocation) => {
142
+ const { filteredListings } = filterListingsByLocation(allListings, selectedLocation, listingEntities);
143
+ setNewFilteredListings(filteredListings);
144
+ };
145
+ const handleSettingFavorites = (newFavorites) => {
146
+ if (newFavorites == null) {
147
+ localStorage.removeItem('favorites');
148
+ }
149
+ else {
150
+ setFavorites(newFavorites);
151
+ localStorage.setItem('favorites', JSON.stringify(newFavorites));
152
+ }
153
+ };
154
+ return (React.createElement(MapListContext.Provider, { value: {
155
+ loading,
156
+ allListings,
157
+ filteredListings,
158
+ mapItems,
159
+ query,
160
+ setNewFilteredListings,
161
+ setQuery,
162
+ listingEntities,
163
+ selectedFilters,
164
+ setSelectedFilters,
165
+ filterOptions,
166
+ recruiters,
167
+ handleFilterListingsByLocation,
168
+ filterDialogIsOpen,
169
+ setFilterDialogIsOpen,
170
+ setMobileTab,
171
+ mobileTab,
172
+ siteConfig,
173
+ favorites,
174
+ handleSettingFavorites,
175
+ setFilterByFavorites,
176
+ filterByFavorites,
177
+ commuteLocation,
178
+ setCommuteLocation,
179
+ navigateToDetails,
180
+ navigateToEasyApply,
181
+ Link,
182
+ linkFormat,
183
+ sortSetting,
184
+ setSortSetting,
185
+ trackEvent
186
+ } }, children));
296
187
  };
297
188
 
298
189
  export { MapListProvider, useMapList };