@abcagency/hc-ui-components 1.3.22 → 1.3.23
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/package.json +4 -1
- package/.env +0 -3
- package/.eslintrc +0 -136
- package/bundleDist/bundle.js +0 -28145
- package/bundleDist/bundle.js.map +0 -1
- package/bundleDist/dist/styles/index.css +0 -3
- package/bundleDist/dist/types/apis/hcApi.d.ts +0 -5
- package/bundleDist/dist/types/clientToken.d.ts +0 -2
- package/bundleDist/dist/types/components/containers/accordions/map-accordion-item-container.d.ts +0 -12
- package/bundleDist/dist/types/components/containers/jobListing/listing-details-container.d.ts +0 -6
- package/bundleDist/dist/types/components/containers/list/item-list-container.d.ts +0 -9
- package/bundleDist/dist/types/components/containers/list/list-item/list-item-container.d.ts +0 -14
- package/bundleDist/dist/types/components/modules/accordions/MapAccordionItem.d.ts +0 -10
- package/bundleDist/dist/types/components/modules/accordions/default.d.ts +0 -19
- package/bundleDist/dist/types/components/modules/buttons/button-group-apply.d.ts +0 -24
- package/bundleDist/dist/types/components/modules/buttons/commute-pill.d.ts +0 -5
- package/bundleDist/dist/types/components/modules/buttons/default.d.ts +0 -48
- package/bundleDist/dist/types/components/modules/buttons/pill-wrapper.d.ts +0 -3
- package/bundleDist/dist/types/components/modules/dialogs/apply-dialog.d.ts +0 -8
- package/bundleDist/dist/types/components/modules/filter/sort.d.ts +0 -8
- package/bundleDist/dist/types/components/modules/grid.d.ts +0 -8
- package/bundleDist/dist/types/components/modules/icon.d.ts +0 -10
- package/bundleDist/dist/types/components/modules/jobListing/listing-details.d.ts +0 -18
- package/bundleDist/dist/types/components/modules/list/field-mapper.d.ts +0 -10
- package/bundleDist/dist/types/components/modules/list/header-item.d.ts +0 -11
- package/bundleDist/dist/types/components/modules/list/header.d.ts +0 -11
- package/bundleDist/dist/types/components/modules/list/item-expand-card/index.d.ts +0 -7
- package/bundleDist/dist/types/components/modules/list/item-expand-card/recruiter-contact-nav.d.ts +0 -17
- package/bundleDist/dist/types/components/modules/list/item-expand-card/recruiter-details.d.ts +0 -21
- package/bundleDist/dist/types/components/modules/list/item-expand-card/recruiter-headshot.d.ts +0 -8
- package/bundleDist/dist/types/components/modules/list/item-list.d.ts +0 -20
- package/bundleDist/dist/types/components/modules/list/list-item/list-item.d.ts +0 -3
- package/bundleDist/dist/types/constants/eventTypes.d.ts +0 -13
- package/bundleDist/dist/types/contexts/mapContext.d.ts +0 -29
- package/bundleDist/dist/types/contexts/mapListContext.d.ts +0 -59
- package/bundleDist/dist/types/contexts/trackEventContext.d.ts +0 -6
- package/bundleDist/dist/types/enums/SectionType.d.ts +0 -9
- package/bundleDist/dist/types/hooks/useList.d.ts +0 -13
- package/bundleDist/dist/types/services/configService.d.ts +0 -6
- package/bundleDist/dist/types/services/googlePlacesNearbyService.d.ts +0 -5
- package/bundleDist/dist/types/services/listingAggregatorService.d.ts +0 -12
- package/bundleDist/dist/types/services/listingEntityService.d.ts +0 -6
- package/bundleDist/dist/types/services/listingService.d.ts +0 -9
- package/bundleDist/dist/types/services/recruiterService.d.ts +0 -6
- package/bundleDist/dist/types/types/Address.d.ts +0 -7
- package/bundleDist/dist/types/types/ContentSection.d.ts +0 -8
- package/bundleDist/dist/types/types/GetListingParams.d.ts +0 -8
- package/bundleDist/dist/types/types/LatLng.d.ts +0 -4
- package/bundleDist/dist/types/types/ListingEntity.d.ts +0 -10
- package/bundleDist/dist/types/types/ListingFields.d.ts +0 -25
- package/bundleDist/dist/types/types/Listings.d.ts +0 -31
- package/bundleDist/dist/types/types/Recruiter.d.ts +0 -9
- package/bundleDist/dist/types/types/SimilarListing.d.ts +0 -24
- package/bundleDist/dist/types/types/config/Colors.d.ts +0 -8
- package/bundleDist/dist/types/types/config/MapConfig.d.ts +0 -30
- package/bundleDist/dist/types/types/config/PointsOfInterestConfig.d.ts +0 -13
- package/bundleDist/dist/types/types/config/SearchConfig.d.ts +0 -4
- package/bundleDist/dist/types/util/filterUtil.d.ts +0 -28
- package/bundleDist/dist/types/util/loading.d.ts +0 -3
- package/bundleDist/dist/types/util/localStorageUtil.d.ts +0 -3
- package/bundleDist/dist/types/util/mapUtil.d.ts +0 -15
- package/bundleDist/dist/types/util/sortUtil.d.ts +0 -1
- package/bundleDist/dist/types/util/stringUtils.d.ts +0 -1
- package/bundleDist/dist/types/util/urlFilterUtil.d.ts +0 -8
- package/bundleDist/styles/index.css +0 -3
- package/bundleDist.map +0 -1
- package/jsconfig.json +0 -7
- package/postcss.config.js +0 -14
- package/preset.default.js +0 -15
- package/rollup.config.mjs +0 -111
- package/src/.editorconfig +0 -12
- package/src/apis/hcApi.ts +0 -109
- package/src/bundleIndex.js +0 -14
- package/src/clientToken.js +0 -9
- package/src/components/HireControlMap.js +0 -135
- package/src/components/containers/accordions/filter-container.js +0 -48
- package/src/components/containers/accordions/filter-item-container.js +0 -66
- package/src/components/containers/accordions/map-accordion-item-container.js +0 -70
- package/src/components/containers/filter/commute-container.js +0 -89
- package/src/components/containers/filter/filter-container.js +0 -76
- package/src/components/containers/filter/filter-item-container.js +0 -71
- package/src/components/containers/filter/location-container.js +0 -45
- package/src/components/containers/filter/points-of-interest-container.js +0 -33
- package/src/components/containers/filter/points-of-interest-radio-item-container.js +0 -35
- package/src/components/containers/filter/search-container.js +0 -50
- package/src/components/containers/jobListing/listing-details-container.js +0 -40
- package/src/components/containers/list/item-list-container.tsx +0 -81
- package/src/components/containers/list/list-item/list-item-container.js +0 -43
- package/src/components/containers/maps/info-window-content-container.js +0 -51
- package/src/components/containers/maps/map-container.js +0 -204
- package/src/components/containers/maps/map-list-container.js +0 -48
- package/src/components/containers/maps/map-marker-container.js +0 -78
- package/src/components/modules/accordions/MapAccordionItem.js +0 -30
- package/src/components/modules/accordions/default.js +0 -171
- package/src/components/modules/accordions/filterItem.js +0 -27
- package/src/components/modules/accordions/filters.js +0 -32
- package/src/components/modules/buttons/button-group-apply.js +0 -123
- package/src/components/modules/buttons/commute-pill.js +0 -22
- package/src/components/modules/buttons/default.js +0 -194
- package/src/components/modules/buttons/items-pill.js +0 -35
- package/src/components/modules/buttons/pill-wrapper.js +0 -27
- package/src/components/modules/buttons/show-all-button.js +0 -20
- package/src/components/modules/cards/default.js +0 -167
- package/src/components/modules/cards/filter.js +0 -56
- package/src/components/modules/dialogs/apply-dialog.js +0 -48
- package/src/components/modules/filter/commute.js +0 -108
- package/src/components/modules/filter/index.js +0 -55
- package/src/components/modules/filter/item.js +0 -48
- package/src/components/modules/filter/location.js +0 -48
- package/src/components/modules/filter/radio-item.js +0 -42
- package/src/components/modules/filter/search.js +0 -65
- package/src/components/modules/filter/sort.js +0 -83
- package/src/components/modules/grid.js +0 -54
- package/src/components/modules/icon.js +0 -33
- package/src/components/modules/jobListing/listing-details.js +0 -109
- package/src/components/modules/list/field-mapper.js +0 -114
- package/src/components/modules/list/header-item.js +0 -91
- package/src/components/modules/list/header.js +0 -49
- package/src/components/modules/list/item-expand-card/index.js +0 -22
- package/src/components/modules/list/item-expand-card/recruiter-contact-nav.js +0 -50
- package/src/components/modules/list/item-expand-card/recruiter-details.js +0 -68
- package/src/components/modules/list/item-expand-card/recruiter-headshot.js +0 -22
- package/src/components/modules/list/item-list.tsx +0 -84
- package/src/components/modules/list/list-item/list-item.js +0 -130
- package/src/components/modules/maps/info-window-card.js +0 -17
- package/src/components/modules/maps/info-window-content.js +0 -35
- package/src/components/modules/maps/map-list.js +0 -28
- package/src/components/modules/maps/map-marker.js +0 -29
- package/src/components/modules/maps/map.js +0 -76
- package/src/components/modules/maps/place-marker.js +0 -41
- package/src/components/modules/maps/tabs.js +0 -81
- package/src/constants/eventTypes.js +0 -13
- package/src/constants/placeTypes.js +0 -8
- package/src/contexts/mapContext.tsx +0 -129
- package/src/contexts/mapListContext.tsx +0 -311
- package/src/contexts/placesContext.js +0 -102
- package/src/contexts/trackEventContext.js +0 -14
- package/src/enums/SectionType.ts +0 -9
- package/src/hooks/useList.js +0 -89
- package/src/index.js +0 -3
- package/src/services/configService.ts +0 -16
- package/src/services/googlePlacesNearbyService.ts +0 -42
- package/src/services/listingAggregatorService.ts +0 -76
- package/src/services/listingEntityService.ts +0 -16
- package/src/services/listingService.ts +0 -40
- package/src/services/recruiterService.ts +0 -18
- package/src/styles/bundle.css +0 -268
- package/src/styles/index.css +0 -24
- package/src/types/Address.ts +0 -7
- package/src/types/ContentSection.ts +0 -9
- package/src/types/GetListingParams.ts +0 -8
- package/src/types/LatLng.ts +0 -4
- package/src/types/ListingEntity.ts +0 -11
- package/src/types/ListingFields.ts +0 -25
- package/src/types/Listings.ts +0 -32
- package/src/types/Recruiter.ts +0 -9
- package/src/types/SimilarListing.ts +0 -24
- package/src/types/config/Colors.ts +0 -8
- package/src/types/config/MapConfig.ts +0 -31
- package/src/types/config/PointsOfInterestConfig.ts +0 -13
- package/src/types/config/SearchConfig.ts +0 -4
- package/src/util/arrayUtil.js +0 -3
- package/src/util/fieldMapper.js +0 -22
- package/src/util/filterUtil.js +0 -239
- package/src/util/loading.js +0 -17
- package/src/util/localStorageUtil.ts +0 -34
- package/src/util/mapIconUtil.js +0 -180
- package/src/util/mapUtil.js +0 -91
- package/src/util/sortUtil.js +0 -33
- package/src/util/stringUtils.js +0 -6
- package/src/util/urlFilterUtil.js +0 -85
- package/stats.html +0 -4842
- package/tailwind.config.js +0 -129
- package/tsconfig.json +0 -23
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Tabs from '~/components/modules/maps/tabs';
|
|
3
|
-
|
|
4
|
-
const MapList = ({ showMap, loading, list, map, filter }) => {
|
|
5
|
-
return (
|
|
6
|
-
<>
|
|
7
|
-
<div
|
|
8
|
-
className={`
|
|
9
|
-
${showMap === false ? "md:hc-grid-rows-[100vh]" : "md:hc-grid-rows-[50vh_50vh]"}
|
|
10
|
-
md:hc-grid md:hc-pt-4 hc-overflow-hidden hc-relative bg-gray-100
|
|
11
|
-
`}
|
|
12
|
-
>
|
|
13
|
-
<div>{list}</div>
|
|
14
|
-
<div>{showMap && map}</div>
|
|
15
|
-
</div>
|
|
16
|
-
<div className="md:hc-hidden">
|
|
17
|
-
<Tabs
|
|
18
|
-
showMap={showMap}
|
|
19
|
-
list={list}
|
|
20
|
-
map={!loading && showMap && map}
|
|
21
|
-
filter={filter}
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
</>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default MapList;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MarkerF } from '@react-google-maps/api';
|
|
3
|
-
|
|
4
|
-
const MapMarker = ({
|
|
5
|
-
position,
|
|
6
|
-
title,
|
|
7
|
-
icon,
|
|
8
|
-
zIndex,
|
|
9
|
-
onLoad,
|
|
10
|
-
onClick,
|
|
11
|
-
clusterer,
|
|
12
|
-
children
|
|
13
|
-
}) => {
|
|
14
|
-
return (
|
|
15
|
-
<MarkerF
|
|
16
|
-
position={position}
|
|
17
|
-
title={title}
|
|
18
|
-
options={{ icon: icon }}
|
|
19
|
-
zIndex={zIndex}
|
|
20
|
-
onLoad={onLoad}
|
|
21
|
-
onClick={onClick}
|
|
22
|
-
clusterer={clusterer}
|
|
23
|
-
>
|
|
24
|
-
{children}
|
|
25
|
-
</MarkerF>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default MapMarker;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { GoogleMap, MarkerClustererF } from "@react-google-maps/api";
|
|
3
|
-
import ShowAllButton from "~/components/modules/buttons/show-all-button";
|
|
4
|
-
import { clusterOptions } from "~/util/mapUtil";
|
|
5
|
-
|
|
6
|
-
const Map = ({
|
|
7
|
-
zoom,
|
|
8
|
-
center,
|
|
9
|
-
mapContainerRef,
|
|
10
|
-
onLoad,
|
|
11
|
-
onIdle,
|
|
12
|
-
clusterGridSize,
|
|
13
|
-
markerConfigs,
|
|
14
|
-
mapMarkers,
|
|
15
|
-
placeMarkers,
|
|
16
|
-
mapInteracted,
|
|
17
|
-
pinIconUrl,
|
|
18
|
-
setMapInteracted,
|
|
19
|
-
fitBounds,
|
|
20
|
-
mapRef,
|
|
21
|
-
setQuery,
|
|
22
|
-
filteredListingsLength,
|
|
23
|
-
setSelectedFilters
|
|
24
|
-
}) => {
|
|
25
|
-
return (
|
|
26
|
-
<>
|
|
27
|
-
{zoom && center && (
|
|
28
|
-
<div ref={mapContainerRef} className="hc-h-full hc-relative">
|
|
29
|
-
<GoogleMap
|
|
30
|
-
zoom={zoom}
|
|
31
|
-
onLoad={onLoad}
|
|
32
|
-
onIdle={onIdle}
|
|
33
|
-
center={center}
|
|
34
|
-
mapContainerStyle={{
|
|
35
|
-
width: "100%",
|
|
36
|
-
height: "100%"
|
|
37
|
-
}}
|
|
38
|
-
options={{
|
|
39
|
-
styles: [
|
|
40
|
-
{
|
|
41
|
-
featureType: "poi",
|
|
42
|
-
elementType: "labels",
|
|
43
|
-
stylers: [{ visibility: "off" }]
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
|
|
49
|
-
{clusterer => (
|
|
50
|
-
<>
|
|
51
|
-
{mapMarkers}
|
|
52
|
-
{placeMarkers}
|
|
53
|
-
</>
|
|
54
|
-
)}
|
|
55
|
-
</MarkerClustererF>
|
|
56
|
-
</GoogleMap>
|
|
57
|
-
{mapInteracted && markerConfigs && (
|
|
58
|
-
<ShowAllButton
|
|
59
|
-
mapInteracted={mapInteracted}
|
|
60
|
-
markerConfigs={markerConfigs}
|
|
61
|
-
setMapInteracted={setMapInteracted}
|
|
62
|
-
fitBounds={fitBounds}
|
|
63
|
-
mapRef={mapRef}
|
|
64
|
-
pinIconUrl={pinIconUrl}
|
|
65
|
-
setQuery={setQuery}
|
|
66
|
-
listingCount={filteredListingsLength}
|
|
67
|
-
setSelectedFilters={setSelectedFilters}
|
|
68
|
-
/>
|
|
69
|
-
)}
|
|
70
|
-
</div>
|
|
71
|
-
)}
|
|
72
|
-
</>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default Map;
|
|
@@ -1,41 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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,13 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
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
|
-
};
|