@abcagency/hc-ui-components 1.3.14 → 1.3.16
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.
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/apis/hcApi.js +1 -1
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/clientToken.js.map +1 -1
- package/dist/components/HireControlMap.js +15 -5
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/modules/accordions/MapAccordionItem.js +11 -1
- package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
- package/dist/components/modules/accordions/default.js.map +1 -1
- package/dist/components/modules/accordions/filterItem.js +2 -1
- package/dist/components/modules/accordions/filterItem.js.map +1 -1
- package/dist/components/modules/accordions/filters.js +0 -3
- package/dist/components/modules/accordions/filters.js.map +1 -1
- package/dist/components/modules/buttons/button-group-apply.js +36 -15
- package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
- package/dist/components/modules/buttons/commute-pill.js.map +1 -1
- package/dist/components/modules/buttons/default.js.map +1 -1
- package/dist/components/modules/buttons/items-pill.js.map +1 -1
- package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
- package/dist/components/modules/buttons/show-all-button.js.map +1 -1
- package/dist/components/modules/cards/default.js.map +1 -1
- package/dist/components/modules/cards/filter.js.map +1 -1
- package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
- package/dist/components/modules/filter/commute.js +22 -6
- package/dist/components/modules/filter/commute.js.map +1 -1
- package/dist/components/modules/filter/index.js +7 -0
- package/dist/components/modules/filter/index.js.map +1 -1
- package/dist/components/modules/filter/item.js +16 -1
- package/dist/components/modules/filter/item.js.map +1 -1
- package/dist/components/modules/filter/location.js +1 -1
- package/dist/components/modules/filter/location.js.map +1 -1
- package/dist/components/modules/filter/points-of-interest.js.map +1 -1
- package/dist/components/modules/filter/radio-item.js +7 -0
- package/dist/components/modules/filter/radio-item.js.map +1 -1
- package/dist/components/modules/filter/search.js.map +1 -1
- package/dist/components/modules/filter/sort.js.map +1 -1
- package/dist/components/modules/grid.js.map +1 -1
- package/dist/components/modules/icon.js.map +1 -1
- package/dist/components/modules/jobListing/listing-details.js +6 -0
- package/dist/components/modules/jobListing/listing-details.js.map +1 -1
- package/dist/components/modules/maps/info-window-card.js.map +1 -1
- package/dist/components/modules/maps/info-window-content.js +20 -0
- package/dist/components/modules/maps/info-window-content.js.map +1 -1
- package/dist/components/modules/maps/list/field-mapper.js.map +1 -1
- package/dist/components/modules/maps/list/header-item.js.map +1 -1
- package/dist/components/modules/maps/list/header.js.map +1 -1
- package/dist/components/modules/maps/list/index.js +21 -12
- package/dist/components/modules/maps/list/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
- package/dist/components/modules/maps/list/list-item/index.js +12 -2
- package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
- package/dist/components/modules/maps/map-list.js.map +1 -1
- package/dist/components/modules/maps/map-marker.js +10 -0
- package/dist/components/modules/maps/map-marker.js.map +1 -1
- package/dist/components/modules/maps/map.js.map +1 -1
- package/dist/components/modules/maps/place-marker.js.map +1 -1
- package/dist/components/modules/maps/tabs.js.map +1 -1
- package/dist/constants/eventTypes.js +16 -0
- package/dist/constants/eventTypes.js.map +1 -0
- package/dist/constants/placeTypes.js.map +1 -1
- package/dist/contexts/mapContext.js +9 -27
- package/dist/contexts/mapContext.js.map +1 -1
- package/dist/contexts/mapListContext.js +57 -38
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/contexts/placesContext.js.map +1 -1
- package/dist/contexts/trackEventContext.js +20 -0
- package/dist/contexts/trackEventContext.js.map +1 -0
- package/dist/hooks/useList.js +1 -13
- package/dist/hooks/useList.js.map +1 -1
- package/dist/services/apis/hcApi.js +1 -1
- package/dist/services/apis/hcApi.js.map +1 -1
- package/dist/services/clientToken.js.map +1 -1
- package/dist/services/configService.js.map +1 -1
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/services/listingAggregatorService.js +43 -16
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js.map +1 -1
- package/dist/services/recruiterService.js.map +1 -1
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/loading.js.map +1 -1
- package/dist/util/localStorageUtil.js.map +1 -1
- package/dist/util/mapIconUtil.js.map +1 -1
- package/dist/util/mapUtil.js.map +1 -1
- package/dist/util/sortUtil.js.map +1 -1
- package/dist/util/stringUtils.js.map +1 -1
- package/jsconfig.json +7 -7
- package/package.json +60 -60
- package/postcss.config.js +13 -13
- package/preset.default.js +15 -15
- package/rollup.config.mjs +88 -87
- package/src/apis/hcApi.js +93 -93
- package/src/clientToken.js +9 -9
- package/src/components/HireControlMap.js +129 -124
- package/src/components/modules/accordions/MapAccordionItem.js +74 -72
- package/src/components/modules/accordions/default.js +171 -171
- package/src/components/modules/accordions/filterItem.js +55 -53
- package/src/components/modules/accordions/filters.js +47 -47
- package/src/components/modules/buttons/button-group-apply.js +123 -116
- package/src/components/modules/buttons/commute-pill.js +22 -22
- package/src/components/modules/buttons/default.js +194 -194
- package/src/components/modules/buttons/items-pill.js +35 -35
- package/src/components/modules/buttons/pill-wrapper.js +27 -27
- package/src/components/modules/buttons/show-all-button.js +20 -20
- package/src/components/modules/cards/default.js +167 -167
- package/src/components/modules/cards/filter.js +56 -56
- package/src/components/modules/dialogs/apply-dialog.js +48 -48
- package/src/components/modules/filter/commute.js +154 -149
- package/src/components/modules/filter/index.js +89 -87
- package/src/components/modules/filter/item.js +87 -76
- package/src/components/modules/filter/location.js +71 -71
- package/src/components/modules/filter/points-of-interest.js +44 -44
- package/src/components/modules/filter/radio-item.js +57 -53
- package/src/components/modules/filter/search.js +92 -92
- package/src/components/modules/filter/sort.js +83 -83
- package/src/components/modules/grid.js +54 -54
- package/src/components/modules/icon.js +33 -33
- package/src/components/modules/jobListing/listing-details.js +99 -95
- package/src/components/modules/maps/info-window-card.js +17 -17
- package/src/components/modules/maps/info-window-content.js +81 -74
- package/src/components/modules/maps/list/field-mapper.js +112 -112
- package/src/components/modules/maps/list/header-item.js +91 -91
- package/src/components/modules/maps/list/header.js +47 -47
- package/src/components/modules/maps/list/index.js +112 -107
- package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
- package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
- package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
- package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
- package/src/components/modules/maps/list/list-item/index.js +135 -133
- package/src/components/modules/maps/map-list.js +74 -74
- package/src/components/modules/maps/map-marker.js +88 -86
- package/src/components/modules/maps/map.js +230 -230
- package/src/components/modules/maps/place-marker.js +41 -41
- package/src/components/modules/maps/tabs.js +81 -81
- package/src/constants/eventTypes.js +13 -0
- package/src/constants/placeTypes.js +8 -8
- package/src/contexts/mapContext.js +101 -115
- package/src/contexts/mapListContext.js +242 -222
- package/src/contexts/placesContext.js +102 -102
- package/src/contexts/trackEventContext.js +14 -0
- package/src/hooks/useList.js +89 -100
- package/src/index.js +3 -3
- package/src/services/configService.js +16 -16
- package/src/services/googlePlacesNearbyService.js +33 -33
- package/src/services/listingAggregatorService.js +50 -45
- package/src/services/listingEntityService.js +15 -15
- package/src/services/listingService.js +26 -26
- package/src/services/recruiterService.js +17 -17
- package/src/styles/index.css +23 -23
- package/src/util/arrayUtil.js +3 -3
- package/src/util/fieldMapper.js +22 -22
- package/src/util/filterUtil.js +195 -195
- package/src/util/loading.js +17 -17
- package/src/util/localStorageUtil.js +26 -26
- package/src/util/mapIconUtil.js +180 -180
- package/src/util/mapUtil.js +91 -91
- package/src/util/sortUtil.js +32 -32
- package/src/util/stringUtils.js +6 -6
- package/src/util/urlFilterUtil.js +90 -90
- package/tailwind.config.js +126 -126
- package/.editorconfig +0 -12
- package/.eslintrc +0 -105
- package/.prettierignore +0 -3
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Marker, InfoWindowF } from '@react-google-maps/api';
|
|
3
|
-
|
|
4
|
-
const PlaceMarker = ({
|
|
5
|
-
marker,
|
|
6
|
-
index,
|
|
7
|
-
selectedPlaceMarker,
|
|
8
|
-
setSelectedPlaceMarker,
|
|
9
|
-
placesWindow,
|
|
10
|
-
setPlacesWindow
|
|
11
|
-
}) => {
|
|
12
|
-
const markerKey = `marker-${marker.title}-${index}`;
|
|
13
|
-
|
|
14
|
-
const placeMarkerClickHandler = () => {
|
|
15
|
-
setSelectedPlaceMarker(markerKey);
|
|
16
|
-
setPlacesWindow(true);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Marker
|
|
21
|
-
key={markerKey}
|
|
22
|
-
position={marker.position}
|
|
23
|
-
title={marker.title}
|
|
24
|
-
icon={marker.icon}
|
|
25
|
-
options={{ optimized: false }}
|
|
26
|
-
onClick={placeMarkerClickHandler}
|
|
27
|
-
>
|
|
28
|
-
{selectedPlaceMarker === markerKey && placesWindow && marker && (
|
|
29
|
-
<InfoWindowF
|
|
30
|
-
position={marker.position}
|
|
31
|
-
onCloseClick={() => setPlacesWindow(false)}
|
|
32
|
-
options={{ maxWidth: 400 }}
|
|
33
|
-
>
|
|
34
|
-
<div>{marker.title}</div>
|
|
35
|
-
</InfoWindowF>
|
|
36
|
-
)}
|
|
37
|
-
</Marker>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default PlaceMarker;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Marker, InfoWindowF } from '@react-google-maps/api';
|
|
3
|
+
|
|
4
|
+
const PlaceMarker = ({
|
|
5
|
+
marker,
|
|
6
|
+
index,
|
|
7
|
+
selectedPlaceMarker,
|
|
8
|
+
setSelectedPlaceMarker,
|
|
9
|
+
placesWindow,
|
|
10
|
+
setPlacesWindow
|
|
11
|
+
}) => {
|
|
12
|
+
const markerKey = `marker-${marker.title}-${index}`;
|
|
13
|
+
|
|
14
|
+
const placeMarkerClickHandler = () => {
|
|
15
|
+
setSelectedPlaceMarker(markerKey);
|
|
16
|
+
setPlacesWindow(true);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Marker
|
|
21
|
+
key={markerKey}
|
|
22
|
+
position={marker.position}
|
|
23
|
+
title={marker.title}
|
|
24
|
+
icon={marker.icon}
|
|
25
|
+
options={{ optimized: false }}
|
|
26
|
+
onClick={placeMarkerClickHandler}
|
|
27
|
+
>
|
|
28
|
+
{selectedPlaceMarker === markerKey && placesWindow && marker && (
|
|
29
|
+
<InfoWindowF
|
|
30
|
+
position={marker.position}
|
|
31
|
+
onCloseClick={() => setPlacesWindow(false)}
|
|
32
|
+
options={{ maxWidth: 400 }}
|
|
33
|
+
>
|
|
34
|
+
<div>{marker.title}</div>
|
|
35
|
+
</InfoWindowF>
|
|
36
|
+
)}
|
|
37
|
+
</Marker>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default PlaceMarker;
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import * as Tabs from '@radix-ui/react-tabs';
|
|
3
|
-
|
|
4
|
-
import Button from '~/components/modules/buttons/default';
|
|
5
|
-
|
|
6
|
-
import { useMapList } from '~/contexts/mapListContext';
|
|
7
|
-
|
|
8
|
-
const MapTabs = ({
|
|
9
|
-
map,
|
|
10
|
-
list,
|
|
11
|
-
filter,
|
|
12
|
-
className,
|
|
13
|
-
showMap
|
|
14
|
-
}) => {
|
|
15
|
-
const tabButtonClasses =
|
|
16
|
-
"hc-flex hc-items-center hc-gap-2 hc-rounded-none hc-border-x-0 data-[state=active]:hc-bg-primary data-[state=active]:hc-text-white";
|
|
17
|
-
const { mobileTab, setMobileTab } = useMapList();
|
|
18
|
-
return (
|
|
19
|
-
<div
|
|
20
|
-
className={`
|
|
21
|
-
hc-relative hc-overflow-hidden
|
|
22
|
-
${className ?? ""}
|
|
23
|
-
`}
|
|
24
|
-
>
|
|
25
|
-
<Tabs.Root
|
|
26
|
-
className="hc-flex hc-flex-col hc-h-screen hc-min-h-screen"
|
|
27
|
-
//defaultValue="listTab"
|
|
28
|
-
value={mobileTab}
|
|
29
|
-
>
|
|
30
|
-
<Tabs.List
|
|
31
|
-
className="hc-w-full hc-shrink-0 hc-flex hc-divide-x hc-divide-primary"
|
|
32
|
-
aria-label="Review positions"
|
|
33
|
-
>
|
|
34
|
-
<Tabs.Trigger value="listTab" asChild onClick={() => setMobileTab("listTab")}>
|
|
35
|
-
<Button.Btn variant="outline" isBlock className={tabButtonClasses}>
|
|
36
|
-
<Button.Body className="hc-justify-center">
|
|
37
|
-
<Button.Icon icon="mdi:view-list" size="hc-size-5" />
|
|
38
|
-
List
|
|
39
|
-
</Button.Body>
|
|
40
|
-
</Button.Btn>
|
|
41
|
-
</Tabs.Trigger>
|
|
42
|
-
{showMap && (
|
|
43
|
-
<Tabs.Trigger value="mapTab" asChild onClick={() => setMobileTab("mapTab")}>
|
|
44
|
-
<Button.Btn
|
|
45
|
-
variant="outline"
|
|
46
|
-
isBlock
|
|
47
|
-
className={tabButtonClasses}
|
|
48
|
-
>
|
|
49
|
-
<Button.Body className="hc-justify-center">
|
|
50
|
-
<Button.Icon icon="mdi:map" size="hc-size-5" />
|
|
51
|
-
Map
|
|
52
|
-
</Button.Body>
|
|
53
|
-
</Button.Btn>
|
|
54
|
-
</Tabs.Trigger>
|
|
55
|
-
)}
|
|
56
|
-
<Tabs.Trigger value="filterTab" asChild onClick={() => setMobileTab("filterTab")}>
|
|
57
|
-
<Button.Btn variant="outline" isBlock className={tabButtonClasses}>
|
|
58
|
-
<Button.Body className="hc-justify-center">
|
|
59
|
-
<Button.Icon icon="fluent:search-12-filled" size="hc-size-5" />
|
|
60
|
-
Filter
|
|
61
|
-
</Button.Body>
|
|
62
|
-
</Button.Btn>
|
|
63
|
-
</Tabs.Trigger>
|
|
64
|
-
</Tabs.List>
|
|
65
|
-
<Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="listTab">
|
|
66
|
-
{list}
|
|
67
|
-
</Tabs.Content>
|
|
68
|
-
{showMap && (
|
|
69
|
-
<Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="mapTab">
|
|
70
|
-
{map}
|
|
71
|
-
</Tabs.Content>
|
|
72
|
-
)}
|
|
73
|
-
<Tabs.Content className="hc-grow hc-bg-white hc-outline-none hc-p-2" value="filterTab">
|
|
74
|
-
{filter}
|
|
75
|
-
</Tabs.Content>
|
|
76
|
-
</Tabs.Root>
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export default MapTabs;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as Tabs from '@radix-ui/react-tabs';
|
|
3
|
+
|
|
4
|
+
import Button from '~/components/modules/buttons/default';
|
|
5
|
+
|
|
6
|
+
import { useMapList } from '~/contexts/mapListContext';
|
|
7
|
+
|
|
8
|
+
const MapTabs = ({
|
|
9
|
+
map,
|
|
10
|
+
list,
|
|
11
|
+
filter,
|
|
12
|
+
className,
|
|
13
|
+
showMap
|
|
14
|
+
}) => {
|
|
15
|
+
const tabButtonClasses =
|
|
16
|
+
"hc-flex hc-items-center hc-gap-2 hc-rounded-none hc-border-x-0 data-[state=active]:hc-bg-primary data-[state=active]:hc-text-white";
|
|
17
|
+
const { mobileTab, setMobileTab } = useMapList();
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={`
|
|
21
|
+
hc-relative hc-overflow-hidden
|
|
22
|
+
${className ?? ""}
|
|
23
|
+
`}
|
|
24
|
+
>
|
|
25
|
+
<Tabs.Root
|
|
26
|
+
className="hc-flex hc-flex-col hc-h-screen hc-min-h-screen"
|
|
27
|
+
//defaultValue="listTab"
|
|
28
|
+
value={mobileTab}
|
|
29
|
+
>
|
|
30
|
+
<Tabs.List
|
|
31
|
+
className="hc-w-full hc-shrink-0 hc-flex hc-divide-x hc-divide-primary"
|
|
32
|
+
aria-label="Review positions"
|
|
33
|
+
>
|
|
34
|
+
<Tabs.Trigger value="listTab" asChild onClick={() => setMobileTab("listTab")}>
|
|
35
|
+
<Button.Btn variant="outline" isBlock className={tabButtonClasses}>
|
|
36
|
+
<Button.Body className="hc-justify-center">
|
|
37
|
+
<Button.Icon icon="mdi:view-list" size="hc-size-5" />
|
|
38
|
+
List
|
|
39
|
+
</Button.Body>
|
|
40
|
+
</Button.Btn>
|
|
41
|
+
</Tabs.Trigger>
|
|
42
|
+
{showMap && (
|
|
43
|
+
<Tabs.Trigger value="mapTab" asChild onClick={() => setMobileTab("mapTab")}>
|
|
44
|
+
<Button.Btn
|
|
45
|
+
variant="outline"
|
|
46
|
+
isBlock
|
|
47
|
+
className={tabButtonClasses}
|
|
48
|
+
>
|
|
49
|
+
<Button.Body className="hc-justify-center">
|
|
50
|
+
<Button.Icon icon="mdi:map" size="hc-size-5" />
|
|
51
|
+
Map
|
|
52
|
+
</Button.Body>
|
|
53
|
+
</Button.Btn>
|
|
54
|
+
</Tabs.Trigger>
|
|
55
|
+
)}
|
|
56
|
+
<Tabs.Trigger value="filterTab" asChild onClick={() => setMobileTab("filterTab")}>
|
|
57
|
+
<Button.Btn variant="outline" isBlock className={tabButtonClasses}>
|
|
58
|
+
<Button.Body className="hc-justify-center">
|
|
59
|
+
<Button.Icon icon="fluent:search-12-filled" size="hc-size-5" />
|
|
60
|
+
Filter
|
|
61
|
+
</Button.Body>
|
|
62
|
+
</Button.Btn>
|
|
63
|
+
</Tabs.Trigger>
|
|
64
|
+
</Tabs.List>
|
|
65
|
+
<Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="listTab">
|
|
66
|
+
{list}
|
|
67
|
+
</Tabs.Content>
|
|
68
|
+
{showMap && (
|
|
69
|
+
<Tabs.Content className="hc-grow hc-bg-white hc-outline-none" value="mapTab">
|
|
70
|
+
{map}
|
|
71
|
+
</Tabs.Content>
|
|
72
|
+
)}
|
|
73
|
+
<Tabs.Content className="hc-grow hc-bg-white hc-outline-none hc-p-2" value="filterTab">
|
|
74
|
+
{filter}
|
|
75
|
+
</Tabs.Content>
|
|
76
|
+
</Tabs.Root>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default MapTabs;
|
|
@@ -0,0 +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,8 +1,8 @@
|
|
|
1
|
-
export const placeTypes = {
|
|
2
|
-
FOOD: "food",
|
|
3
|
-
STORE: "shopping",
|
|
4
|
-
TOURIST_ATTRACTION: "attractions",
|
|
5
|
-
TRANSIT_STATION: "transit",
|
|
6
|
-
SCHOOL: "schools",
|
|
7
|
-
PLACE_OF_WORSHIP: "worship"
|
|
8
|
-
};
|
|
1
|
+
export const placeTypes = {
|
|
2
|
+
FOOD: "food",
|
|
3
|
+
STORE: "shopping",
|
|
4
|
+
TOURIST_ATTRACTION: "attractions",
|
|
5
|
+
TRANSIT_STATION: "transit",
|
|
6
|
+
SCHOOL: "schools",
|
|
7
|
+
PLACE_OF_WORSHIP: "worship"
|
|
8
|
+
};
|
|
@@ -1,115 +1,101 @@
|
|
|
1
|
-
import React, { createContext, useState, useContext, useEffect, useRef } from 'react';
|
|
2
|
-
import { getStorageObject, setStorageObject } from '~/util/localStorageUtil';
|
|
3
|
-
|
|
4
|
-
const MapContext = createContext();
|
|
5
|
-
|
|
6
|
-
export const useMap = () => {
|
|
7
|
-
const context = useContext(MapContext);
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useMap must be used within a MapProvider");
|
|
10
|
-
}
|
|
11
|
-
return context;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const MapProvider = ({ children, resetFilters }) => {
|
|
15
|
-
const [selectedListItem, setSelectedListItem] = useState(getStorageObject('selectedListItem'));
|
|
16
|
-
const [location, setLocation] = useState(getStorageObject('location'));
|
|
17
|
-
const [center, setCenter] = useState(getStorageObject("center", { lat: 39.8283, lng: -98.5795 }));
|
|
18
|
-
const [zoom, setZoom] = useState(getStorageObject("zoom", 10));
|
|
19
|
-
const [
|
|
20
|
-
const [
|
|
21
|
-
const [
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
setLocation,
|
|
103
|
-
setMapInteracted,
|
|
104
|
-
mapInteracted,
|
|
105
|
-
userSetZoom,
|
|
106
|
-
firstLoadListItem,
|
|
107
|
-
travelTime,
|
|
108
|
-
setTravelTime,
|
|
109
|
-
filterReset
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
{children}
|
|
113
|
-
</MapContext.Provider>
|
|
114
|
-
);
|
|
115
|
-
};
|
|
1
|
+
import React, { createContext, useState, useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import { getStorageObject, setStorageObject } from '~/util/localStorageUtil';
|
|
3
|
+
|
|
4
|
+
const MapContext = createContext();
|
|
5
|
+
|
|
6
|
+
export const useMap = () => {
|
|
7
|
+
const context = useContext(MapContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("useMap must be used within a MapProvider");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const MapProvider = ({ children, resetFilters }) => {
|
|
15
|
+
const [selectedListItem, setSelectedListItem] = useState(getStorageObject('selectedListItem'));
|
|
16
|
+
const [location, setLocation] = useState(getStorageObject('location'));
|
|
17
|
+
const [center, setCenter] = useState(getStorageObject("center", { lat: 39.8283, lng: -98.5795 }));
|
|
18
|
+
const [zoom, setZoom] = useState(getStorageObject("zoom", 10));
|
|
19
|
+
const [selectedPlaces, setSelectedPlaces] = useState([]);
|
|
20
|
+
const [mapInteracted, setMapInteracted] = useState(false);
|
|
21
|
+
const [firstLoadListItem] = useState(getStorageObject('selectedListItem') ?? { id: "defaultId" });
|
|
22
|
+
const userSetZoom = useRef(true);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setStorageObject("selectedListItem", selectedListItem);
|
|
26
|
+
}, [selectedListItem]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
localStorage.setItem("zoom", zoom);
|
|
30
|
+
}, [zoom]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (location == null) {
|
|
34
|
+
localStorage.removeItem("location");
|
|
35
|
+
} else {
|
|
36
|
+
setStorageObject("location", location);
|
|
37
|
+
}
|
|
38
|
+
}, [location]);
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setStorageObject("center", center);
|
|
42
|
+
}, [center]);
|
|
43
|
+
|
|
44
|
+
const selectItem = (item, itemLocation, zoom, center) => {
|
|
45
|
+
setSelectedListItem(item);
|
|
46
|
+
if (mapInteracted === false && itemLocation != null) {
|
|
47
|
+
setLocation(itemLocation);
|
|
48
|
+
}
|
|
49
|
+
if (mapInteracted === false || itemLocation != null) {
|
|
50
|
+
setLocation(itemLocation);
|
|
51
|
+
setCenter(center);
|
|
52
|
+
}
|
|
53
|
+
if (mapInteracted === false) {
|
|
54
|
+
setZoom(zoom);
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const filterReset = () => {
|
|
60
|
+
setSelectedPlaces({});
|
|
61
|
+
setSelectedListItem(null);
|
|
62
|
+
setLocation(null);
|
|
63
|
+
setZoom(8);
|
|
64
|
+
setMapInteracted(false);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if (resetFilters === true) {
|
|
68
|
+
filterReset();
|
|
69
|
+
}
|
|
70
|
+
const selectLocationEntity = location => {
|
|
71
|
+
|
|
72
|
+
localStorage.removeItem("selectedListItem");
|
|
73
|
+
setTimeout(() => setLocation(location), 200);
|
|
74
|
+
setSelectedListItem(null);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<MapContext.Provider
|
|
79
|
+
value={{
|
|
80
|
+
selectedListItem,
|
|
81
|
+
setSelectedListItem,
|
|
82
|
+
location,
|
|
83
|
+
center,
|
|
84
|
+
zoom,
|
|
85
|
+
setZoom,
|
|
86
|
+
selectItem,
|
|
87
|
+
setSelectedPlaces,
|
|
88
|
+
selectedPlaces,
|
|
89
|
+
selectLocationEntity,
|
|
90
|
+
setLocation,
|
|
91
|
+
setMapInteracted,
|
|
92
|
+
mapInteracted,
|
|
93
|
+
userSetZoom,
|
|
94
|
+
firstLoadListItem,
|
|
95
|
+
filterReset
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{children}
|
|
99
|
+
</MapContext.Provider>
|
|
100
|
+
);
|
|
101
|
+
};
|