@abcagency/hc-ui-components 1.3.58 → 1.3.59
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/apis/hcApi.js +85 -85
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/clientToken.js.map +1 -1
- package/dist/components/containers/accordions/filter-container.js.map +1 -1
- package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
- package/dist/components/containers/jobListing/listing-details-container.js.map +1 -1
- package/dist/components/containers/list/item-list-container.js +21 -21
- package/dist/components/containers/list/list-item/list-item-container.js.map +1 -1
- package/dist/components/containers/maps/map-container.js.map +1 -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/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/filter/item.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/list/header.js.map +1 -1
- package/dist/components/modules/list/item-list.js +40 -40
- package/dist/components/modules/maps/info-window-card.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/placeTypes.js.map +1 -1
- package/dist/contexts/mapContext.js +83 -83
- package/dist/contexts/mapListContext.js +190 -190
- package/dist/contexts/trackEventContext.js.map +1 -1
- package/dist/hooks/useList.js.map +1 -1
- package/dist/services/configService.js +9 -9
- package/dist/services/googlePlacesNearbyService.js +32 -32
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/services/listingAggregatorService.js +34 -34
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js +9 -9
- package/dist/services/listingService.js +24 -24
- package/dist/services/recruiterService.js +10 -10
- package/dist/types/apis/hcApi.d.ts +5 -5
- package/dist/types/clientToken.d.ts +2 -2
- package/dist/types/components/containers/accordions/map-accordion-item-container.d.ts +12 -12
- package/dist/types/components/containers/jobListing/listing-details-container.d.ts +6 -6
- package/dist/types/components/containers/list/item-list-container.d.ts +9 -9
- package/dist/types/components/containers/list/list-item/list-item-container.d.ts +14 -14
- package/dist/types/components/modules/accordions/MapAccordionItem.d.ts +10 -10
- package/dist/types/components/modules/accordions/default.d.ts +19 -19
- package/dist/types/components/modules/buttons/button-group-apply.d.ts +24 -24
- package/dist/types/components/modules/buttons/commute-pill.d.ts +5 -5
- package/dist/types/components/modules/buttons/default.d.ts +48 -48
- package/dist/types/components/modules/buttons/pill-wrapper.d.ts +3 -3
- package/dist/types/components/modules/dialogs/apply-dialog.d.ts +8 -8
- package/dist/types/components/modules/filter/sort.d.ts +8 -8
- package/dist/types/components/modules/grid.d.ts +8 -8
- package/dist/types/components/modules/icon.d.ts +10 -10
- package/dist/types/components/modules/jobListing/listing-details.d.ts +18 -18
- package/dist/types/components/modules/list/field-mapper.d.ts +10 -10
- package/dist/types/components/modules/list/header-item.d.ts +11 -11
- package/dist/types/components/modules/list/header.d.ts +12 -12
- package/dist/types/components/modules/list/item-expand-card/index.d.ts +7 -7
- package/dist/types/components/modules/list/item-expand-card/recruiter-contact-nav.d.ts +17 -17
- package/dist/types/components/modules/list/item-expand-card/recruiter-details.d.ts +21 -21
- package/dist/types/components/modules/list/item-expand-card/recruiter-headshot.d.ts +8 -8
- package/dist/types/components/modules/list/item-list.d.ts +20 -20
- package/dist/types/components/modules/list/list-item/list-item.d.ts +3 -3
- package/dist/types/constants/eventTypes.d.ts +14 -14
- package/dist/types/contexts/mapContext.d.ts +29 -29
- package/dist/types/contexts/mapListContext.d.ts +61 -61
- package/dist/types/contexts/trackEventContext.d.ts +6 -6
- package/dist/types/enums/SectionType.d.ts +9 -9
- package/dist/types/hooks/useList.d.ts +13 -13
- package/dist/types/services/configService.d.ts +6 -6
- package/dist/types/services/googlePlacesNearbyService.d.ts +5 -5
- package/dist/types/services/listingAggregatorService.d.ts +12 -12
- package/dist/types/services/listingEntityService.d.ts +6 -6
- package/dist/types/services/listingService.d.ts +9 -9
- package/dist/types/services/recruiterService.d.ts +6 -6
- package/dist/types/types/Address.d.ts +7 -7
- package/dist/types/types/ContentSection.d.ts +8 -8
- package/dist/types/types/GetListingParams.d.ts +8 -8
- package/dist/types/types/LatLng.d.ts +4 -4
- package/dist/types/types/ListingEntity.d.ts +10 -10
- package/dist/types/types/ListingFields.d.ts +25 -25
- package/dist/types/types/Listings.d.ts +31 -31
- package/dist/types/types/Recruiter.d.ts +9 -9
- package/dist/types/types/SimilarListing.d.ts +24 -24
- package/dist/types/types/config/Colors.d.ts +8 -8
- package/dist/types/types/config/MapConfig.d.ts +30 -30
- package/dist/types/types/config/PointsOfInterestConfig.d.ts +13 -13
- package/dist/types/types/config/SearchConfig.d.ts +4 -4
- package/dist/types/util/filterUtil.d.ts +28 -28
- package/dist/types/util/loading.d.ts +3 -3
- package/dist/types/util/localStorageUtil.d.ts +3 -3
- package/dist/types/util/mapUtil.d.ts +16 -16
- package/dist/types/util/sortUtil.d.ts +1 -1
- package/dist/types/util/stringUtils.d.ts +1 -1
- package/dist/types/util/urlFilterUtil.d.ts +8 -8
- package/dist/util/filterUtil.js +2 -2
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/loading.js.map +1 -1
- package/dist/util/localStorageUtil.js +37 -37
- package/dist/util/localStorageUtil.js.map +1 -1
- package/dist/util/sortUtil.js.map +1 -1
- package/dist/util/stringUtils.js.map +1 -1
- package/dist/util/urlFilterUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/apis/hcApi.ts +109 -109
- package/src/clientToken.js +9 -9
- package/src/components/containers/accordions/filter-container.js +48 -48
- package/src/components/containers/accordions/map-accordion-item-container.js +70 -70
- package/src/components/containers/jobListing/listing-details-container.js +40 -40
- package/src/components/containers/list/list-item/list-item-container.js +43 -43
- package/src/components/containers/maps/map-container.js +249 -249
- package/src/components/modules/accordions/MapAccordionItem.js +30 -30
- package/src/components/modules/accordions/default.js +171 -171
- 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 +19 -19
- package/src/components/modules/cards/default.js +167 -167
- package/src/components/modules/cards/filter.js +56 -56
- package/src/components/modules/filter/item.js +69 -69
- 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/list/header.js +51 -51
- package/src/components/modules/list/item-expand-card/recruiter-contact-nav.js +50 -50
- package/src/components/modules/list/item-expand-card/recruiter-details.js +68 -68
- package/src/components/modules/list/item-expand-card/recruiter-headshot.js +22 -22
- package/src/components/modules/maps/info-window-card.js +17 -17
- package/src/components/modules/maps/map.js +64 -64
- package/src/components/modules/maps/place-marker.js +41 -41
- package/src/components/modules/maps/tabs.js +81 -81
- package/src/constants/placeTypes.js +8 -8
- package/src/contexts/trackEventContext.js +14 -14
- package/src/enums/SectionType.ts +9 -9
- package/src/hooks/useList.js +89 -89
- package/src/index.js +3 -3
- package/src/services/googlePlacesNearbyService.ts +42 -42
- package/src/services/listingAggregatorService.ts +76 -76
- package/src/util/arrayUtil.js +3 -3
- package/src/util/fieldMapper.js +22 -22
- package/src/util/filterUtil.js +311 -310
- package/src/util/loading.js +17 -17
- package/src/util/localStorageUtil.ts +34 -34
- package/src/util/sortUtil.js +32 -32
- package/src/util/stringUtils.js +6 -6
- package/src/util/urlFilterUtil.js +85 -85
- package/dist/types/contexts/themeContext.d.ts +0 -11
package/src/hooks/useList.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { useEffect, useState, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { getStorageObject } from '~/util/localStorageUtil';
|
|
4
|
-
|
|
5
|
-
const getDefaultItemId = () => {
|
|
6
|
-
let item = getStorageObject("selectedListItem");
|
|
7
|
-
if (item?.expanded == true) {
|
|
8
|
-
return item.id;
|
|
9
|
-
} else {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const useListLogic = filteredListings => {
|
|
15
|
-
const [itemLimit, setItemLimit] = useState(100);
|
|
16
|
-
const [expandedId] = useState(getDefaultItemId());
|
|
17
|
-
const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
|
|
18
|
-
const [scrollPosition, setScrollPosition] = useState(getStorageObject('scrollPosition', 0));
|
|
19
|
-
const loader = useRef(null);
|
|
20
|
-
const scrollContainerRef = useRef(null);
|
|
21
|
-
const itemRefs = useRef({});
|
|
22
|
-
const observer = useRef(null);
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
observer.current = new IntersectionObserver(handleObserver, {
|
|
26
|
-
root: scrollContainerRef.current,
|
|
27
|
-
rootMargin: "100px 0px",
|
|
28
|
-
threshold: 0.5
|
|
29
|
-
});
|
|
30
|
-
const { current } = loader;
|
|
31
|
-
if (current) {
|
|
32
|
-
observer.current.observe(current);
|
|
33
|
-
}
|
|
34
|
-
return () => {
|
|
35
|
-
if (observer.current && current) {
|
|
36
|
-
observer.current.unobserve(current);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
-
}, [filteredListings.length, itemLimit]);
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
localStorage.setItem('scrollPosition', scrollPosition.toString());
|
|
44
|
-
}, [scrollPosition]);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
const savedScrollPosition = scrollPosition;
|
|
48
|
-
if (parseInt(savedScrollPosition) > 3000) {
|
|
49
|
-
setItemLimit(savedScrollPosition / 10);
|
|
50
|
-
}
|
|
51
|
-
if (savedScrollPosition && scrollContainerRef.current) {
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
scrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);
|
|
54
|
-
}, 300);
|
|
55
|
-
}
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const { current } = scrollContainerRef;
|
|
60
|
-
if (current) {
|
|
61
|
-
current.addEventListener('scroll', handleScroll);
|
|
62
|
-
}
|
|
63
|
-
return () => {
|
|
64
|
-
if (current) {
|
|
65
|
-
current.removeEventListener('scroll', handleScroll);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
const handleObserver = entities => {
|
|
71
|
-
const target = entities[0];
|
|
72
|
-
if (!target.isIntersecting) return;
|
|
73
|
-
if (filteredListings.length > itemLimit) {
|
|
74
|
-
setItemLimit(prevLimit => prevLimit + 100);
|
|
75
|
-
} else if (observer.current) {
|
|
76
|
-
observer.current.disconnect();
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const handleScroll = () => {
|
|
81
|
-
if (scrollContainerRef.current) {
|
|
82
|
-
setScrollPosition(scrollContainerRef.current.scrollTop);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, filteredListings };
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export default useListLogic;
|
|
1
|
+
import { useEffect, useState, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { getStorageObject } from '~/util/localStorageUtil';
|
|
4
|
+
|
|
5
|
+
const getDefaultItemId = () => {
|
|
6
|
+
let item = getStorageObject("selectedListItem");
|
|
7
|
+
if (item?.expanded == true) {
|
|
8
|
+
return item.id;
|
|
9
|
+
} else {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const useListLogic = filteredListings => {
|
|
15
|
+
const [itemLimit, setItemLimit] = useState(100);
|
|
16
|
+
const [expandedId] = useState(getDefaultItemId());
|
|
17
|
+
const [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));
|
|
18
|
+
const [scrollPosition, setScrollPosition] = useState(getStorageObject('scrollPosition', 0));
|
|
19
|
+
const loader = useRef(null);
|
|
20
|
+
const scrollContainerRef = useRef(null);
|
|
21
|
+
const itemRefs = useRef({});
|
|
22
|
+
const observer = useRef(null);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
observer.current = new IntersectionObserver(handleObserver, {
|
|
26
|
+
root: scrollContainerRef.current,
|
|
27
|
+
rootMargin: "100px 0px",
|
|
28
|
+
threshold: 0.5
|
|
29
|
+
});
|
|
30
|
+
const { current } = loader;
|
|
31
|
+
if (current) {
|
|
32
|
+
observer.current.observe(current);
|
|
33
|
+
}
|
|
34
|
+
return () => {
|
|
35
|
+
if (observer.current && current) {
|
|
36
|
+
observer.current.unobserve(current);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [filteredListings.length, itemLimit]);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
localStorage.setItem('scrollPosition', scrollPosition.toString());
|
|
44
|
+
}, [scrollPosition]);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const savedScrollPosition = scrollPosition;
|
|
48
|
+
if (parseInt(savedScrollPosition) > 3000) {
|
|
49
|
+
setItemLimit(savedScrollPosition / 10);
|
|
50
|
+
}
|
|
51
|
+
if (savedScrollPosition && scrollContainerRef.current) {
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
scrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);
|
|
54
|
+
}, 300);
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const { current } = scrollContainerRef;
|
|
60
|
+
if (current) {
|
|
61
|
+
current.addEventListener('scroll', handleScroll);
|
|
62
|
+
}
|
|
63
|
+
return () => {
|
|
64
|
+
if (current) {
|
|
65
|
+
current.removeEventListener('scroll', handleScroll);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
const handleObserver = entities => {
|
|
71
|
+
const target = entities[0];
|
|
72
|
+
if (!target.isIntersecting) return;
|
|
73
|
+
if (filteredListings.length > itemLimit) {
|
|
74
|
+
setItemLimit(prevLimit => prevLimit + 100);
|
|
75
|
+
} else if (observer.current) {
|
|
76
|
+
observer.current.disconnect();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const handleScroll = () => {
|
|
81
|
+
if (scrollContainerRef.current) {
|
|
82
|
+
setScrollPosition(scrollContainerRef.current.scrollTop);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, filteredListings };
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default useListLogic;
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import HireControlMap from '~/components/HireControlMap';
|
|
2
|
-
|
|
3
|
-
export { HireControlMap };
|
|
1
|
+
import HireControlMap from '~/components/HireControlMap';
|
|
2
|
+
|
|
3
|
+
export { HireControlMap };
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
export interface Location {
|
|
2
|
-
latitude: number;
|
|
3
|
-
longitude: number;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export const searchNearbyPlaces = async (
|
|
7
|
-
typesArray: string[],
|
|
8
|
-
location: Location,
|
|
9
|
-
radius: number
|
|
10
|
-
): Promise<any> => {
|
|
11
|
-
const url = 'https://places.googleapis.com/v1/places:searchNearby';
|
|
12
|
-
const headers = {
|
|
13
|
-
'Content-Type': 'application/json',
|
|
14
|
-
'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY as string,
|
|
15
|
-
'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
|
|
16
|
-
};
|
|
17
|
-
const data = {
|
|
18
|
-
includedTypes: typesArray,
|
|
19
|
-
maxResultCount: 20,
|
|
20
|
-
locationRestriction: {
|
|
21
|
-
circle: {
|
|
22
|
-
center: location,
|
|
23
|
-
radius: radius
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const response = await fetch(url, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
headers: headers,
|
|
32
|
-
body: JSON.stringify(data)
|
|
33
|
-
});
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
36
|
-
}
|
|
37
|
-
return await response.json();
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error('Error making the Nearby Search request:', error);
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
1
|
+
export interface Location {
|
|
2
|
+
latitude: number;
|
|
3
|
+
longitude: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const searchNearbyPlaces = async (
|
|
7
|
+
typesArray: string[],
|
|
8
|
+
location: Location,
|
|
9
|
+
radius: number
|
|
10
|
+
): Promise<any> => {
|
|
11
|
+
const url = 'https://places.googleapis.com/v1/places:searchNearby';
|
|
12
|
+
const headers = {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
'X-Goog-Api-Key': process.env.GOOGLE_MAPS_API_KEY as string,
|
|
15
|
+
'X-Goog-FieldMask': 'places.location,places.displayName,places.types'
|
|
16
|
+
};
|
|
17
|
+
const data = {
|
|
18
|
+
includedTypes: typesArray,
|
|
19
|
+
maxResultCount: 20,
|
|
20
|
+
locationRestriction: {
|
|
21
|
+
circle: {
|
|
22
|
+
center: location,
|
|
23
|
+
radius: radius
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const response = await fetch(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: headers,
|
|
32
|
+
body: JSON.stringify(data)
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
36
|
+
}
|
|
37
|
+
return await response.json();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error making the Nearby Search request:', error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { getListings } from '~/services/listingService';
|
|
2
|
-
import { getRecruiters } from '~/services/recruiterService';
|
|
3
|
-
import { getListingEntities } from '~/services/listingEntityService';
|
|
4
|
-
|
|
5
|
-
import { getDistinctItemsByProximity } from '~/util/mapUtil';
|
|
6
|
-
import { Listing } from '~/types/Listings';
|
|
7
|
-
import { Recruiter } from '~/types/Recruiter';
|
|
8
|
-
import { ListingEntity } from '~/types/ListingEntity';
|
|
9
|
-
import { MapConfig } from '~/types/config/MapConfig';
|
|
10
|
-
//import { ICommuteLocation } from '~/interfaces/ICommute';
|
|
11
|
-
|
|
12
|
-
interface SiteConfig {
|
|
13
|
-
companyId: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface FetchListingsResult {
|
|
17
|
-
listingsResult: Listing[];
|
|
18
|
-
fetchedRecruiters: Recruiter[];
|
|
19
|
-
fetchedEntities: Record<number, ListingEntity>;
|
|
20
|
-
distinctItems: any; // Update this type based on the return type of getDistinctItemsByProximity
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const fetchListings = async (
|
|
24
|
-
query: string,
|
|
25
|
-
siteConfig: MapConfig,
|
|
26
|
-
commuteLocation: any | null = null
|
|
27
|
-
): Promise<FetchListingsResult> => {
|
|
28
|
-
try {
|
|
29
|
-
const listingsResult = await getListings(
|
|
30
|
-
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const recruiterIds: number[] = [
|
|
34
|
-
...new Set(listingsResult.map(listing => listing.recruiterId))
|
|
35
|
-
] as number[];
|
|
36
|
-
|
|
37
|
-
const fetchedRecruiters = await getRecruiters(recruiterIds);
|
|
38
|
-
|
|
39
|
-
const distinctEntityIds: number[] = [
|
|
40
|
-
...new Set(listingsResult.map(listing => listing.entityId))
|
|
41
|
-
] as number[];
|
|
42
|
-
|
|
43
|
-
const fetchedEntities = !commuteLocation
|
|
44
|
-
? await getListingEntities(distinctEntityIds)
|
|
45
|
-
: await getListingEntities(
|
|
46
|
-
distinctEntityIds,
|
|
47
|
-
`${commuteLocation.lat}, ${commuteLocation.lng}`
|
|
48
|
-
);
|
|
49
|
-
for (let i = 0; i < listingsResult.length; i++) {
|
|
50
|
-
const listing = listingsResult[i];
|
|
51
|
-
if (listing.entityId && listing.entityId !== -1 && listing.fields) {
|
|
52
|
-
const entity = fetchedEntities[listing.entityId];
|
|
53
|
-
if (entity) {
|
|
54
|
-
listing.fields.travelTime = entity.travelTime;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const distinctItems = getDistinctItemsByProximity(
|
|
60
|
-
listingsResult,
|
|
61
|
-
fetchedEntities
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
listingsResult,
|
|
66
|
-
fetchedRecruiters,
|
|
67
|
-
fetchedEntities,
|
|
68
|
-
distinctItems
|
|
69
|
-
};
|
|
70
|
-
} catch (error) {
|
|
71
|
-
console.error("Error fetching listings:", error);
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default fetchListings;
|
|
1
|
+
import { getListings } from '~/services/listingService';
|
|
2
|
+
import { getRecruiters } from '~/services/recruiterService';
|
|
3
|
+
import { getListingEntities } from '~/services/listingEntityService';
|
|
4
|
+
|
|
5
|
+
import { getDistinctItemsByProximity } from '~/util/mapUtil';
|
|
6
|
+
import { Listing } from '~/types/Listings';
|
|
7
|
+
import { Recruiter } from '~/types/Recruiter';
|
|
8
|
+
import { ListingEntity } from '~/types/ListingEntity';
|
|
9
|
+
import { MapConfig } from '~/types/config/MapConfig';
|
|
10
|
+
//import { ICommuteLocation } from '~/interfaces/ICommute';
|
|
11
|
+
|
|
12
|
+
interface SiteConfig {
|
|
13
|
+
companyId: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface FetchListingsResult {
|
|
17
|
+
listingsResult: Listing[];
|
|
18
|
+
fetchedRecruiters: Recruiter[];
|
|
19
|
+
fetchedEntities: Record<number, ListingEntity>;
|
|
20
|
+
distinctItems: any; // Update this type based on the return type of getDistinctItemsByProximity
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const fetchListings = async (
|
|
24
|
+
query: string,
|
|
25
|
+
siteConfig: MapConfig,
|
|
26
|
+
commuteLocation: any | null = null
|
|
27
|
+
): Promise<FetchListingsResult> => {
|
|
28
|
+
try {
|
|
29
|
+
const listingsResult = await getListings(
|
|
30
|
+
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const recruiterIds: number[] = [
|
|
34
|
+
...new Set(listingsResult.map(listing => listing.recruiterId))
|
|
35
|
+
] as number[];
|
|
36
|
+
|
|
37
|
+
const fetchedRecruiters = await getRecruiters(recruiterIds);
|
|
38
|
+
|
|
39
|
+
const distinctEntityIds: number[] = [
|
|
40
|
+
...new Set(listingsResult.map(listing => listing.entityId))
|
|
41
|
+
] as number[];
|
|
42
|
+
|
|
43
|
+
const fetchedEntities = !commuteLocation
|
|
44
|
+
? await getListingEntities(distinctEntityIds)
|
|
45
|
+
: await getListingEntities(
|
|
46
|
+
distinctEntityIds,
|
|
47
|
+
`${commuteLocation.lat}, ${commuteLocation.lng}`
|
|
48
|
+
);
|
|
49
|
+
for (let i = 0; i < listingsResult.length; i++) {
|
|
50
|
+
const listing = listingsResult[i];
|
|
51
|
+
if (listing.entityId && listing.entityId !== -1 && listing.fields) {
|
|
52
|
+
const entity = fetchedEntities[listing.entityId];
|
|
53
|
+
if (entity) {
|
|
54
|
+
listing.fields.travelTime = entity.travelTime;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const distinctItems = getDistinctItemsByProximity(
|
|
60
|
+
listingsResult,
|
|
61
|
+
fetchedEntities
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
listingsResult,
|
|
66
|
+
fetchedRecruiters,
|
|
67
|
+
fetchedEntities,
|
|
68
|
+
distinctItems
|
|
69
|
+
};
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("Error fetching listings:", error);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default fetchListings;
|
package/src/util/arrayUtil.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const onlyUnique = (value, index, array) => {
|
|
2
|
-
return array.indexOf(value) === index;
|
|
3
|
-
};
|
|
1
|
+
export const onlyUnique = (value, index, array) => {
|
|
2
|
+
return array.indexOf(value) === index;
|
|
3
|
+
};
|
package/src/util/fieldMapper.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import Grid from '~/components/modules/grid';
|
|
4
|
-
|
|
5
|
-
import { capitalize } from '~/util/stringUtils';
|
|
6
|
-
|
|
7
|
-
const mapFieldsToGridItems = (item, fieldsShown) => {
|
|
8
|
-
const orderedFields = fieldsShown.filter(field => field in item.fields);
|
|
9
|
-
|
|
10
|
-
return orderedFields.map(field => {
|
|
11
|
-
let value = item.fields[field];
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Grid.Item key={field}>
|
|
15
|
-
<span className="hc-sr-only">{capitalize(field)}</span>
|
|
16
|
-
{value}
|
|
17
|
-
</Grid.Item>
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default mapFieldsToGridItems;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Grid from '~/components/modules/grid';
|
|
4
|
+
|
|
5
|
+
import { capitalize } from '~/util/stringUtils';
|
|
6
|
+
|
|
7
|
+
const mapFieldsToGridItems = (item, fieldsShown) => {
|
|
8
|
+
const orderedFields = fieldsShown.filter(field => field in item.fields);
|
|
9
|
+
|
|
10
|
+
return orderedFields.map(field => {
|
|
11
|
+
let value = item.fields[field];
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Grid.Item key={field}>
|
|
15
|
+
<span className="hc-sr-only">{capitalize(field)}</span>
|
|
16
|
+
{value}
|
|
17
|
+
</Grid.Item>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default mapFieldsToGridItems;
|