@abcagency/hc-ui-components 1.4.5 → 1.4.8
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/components/HireControlMap.js +4 -0
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/containers/accordions/map-accordion-item-container.js +1 -3
- package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
- package/dist/components/containers/maps/info-window-content-container.js.map +1 -1
- package/dist/components/containers/maps/map-container.js +1 -0
- package/dist/components/containers/maps/map-container.js.map +1 -1
- package/dist/components/modules/buttons/button-group-apply.js +4 -4
- package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
- package/dist/contexts/mapListContext.js +15 -17
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/services/listingAggregatorService.js +11 -12
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js +2 -3
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js +16 -10
- package/dist/services/listingService.js.map +1 -1
- package/dist/types/contexts/mapListContext.d.ts +1 -0
- package/dist/types/services/listingAggregatorService.d.ts +2 -2
- package/dist/types/services/listingEntityService.d.ts +3 -2
- package/dist/types/types/ListingEntity.d.ts +1 -2
- package/dist/types/types/ListingFields.d.ts +2 -4
- package/dist/types/types/Listings.d.ts +1 -0
- package/dist/types/util/mapUtil.d.ts +3 -3
- package/dist/util/mapUtil.js +25 -33
- package/dist/util/mapUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/components/HireControlMap.js +5 -0
- package/src/components/containers/accordions/map-accordion-item-container.js +1 -3
- package/src/components/containers/maps/info-window-content-container.js +1 -1
- package/src/components/containers/maps/map-container.js +1 -2
- package/src/components/modules/buttons/button-group-apply.js +4 -4
- package/src/contexts/mapListContext.tsx +21 -18
- package/src/services/listingAggregatorService.ts +17 -16
- package/src/services/listingEntityService.ts +3 -3
- package/src/services/listingService.ts +10 -11
- package/src/types/ListingEntity.ts +1 -2
- package/src/types/ListingFields.ts +2 -4
- package/src/types/Listings.ts +1 -0
- package/src/util/mapUtil.js +41 -48
|
@@ -11,6 +11,7 @@ import { Listing } from '~/types/Listings';
|
|
|
11
11
|
import { ListingEntity } from '~/types/ListingEntity';
|
|
12
12
|
import { Recruiter } from '~/types/Recruiter';
|
|
13
13
|
import { MapConfig, MapConfig as SiteConfig } from '~/types/config/MapConfig';
|
|
14
|
+
import { get } from 'http';
|
|
14
15
|
|
|
15
16
|
interface MapListContextProps {
|
|
16
17
|
loading: boolean;
|
|
@@ -92,6 +93,7 @@ interface MapListProviderProps {
|
|
|
92
93
|
defaultFilters?: Record<string, any>;
|
|
93
94
|
containerStyle?: any;
|
|
94
95
|
localStorageKey: string;
|
|
96
|
+
getListingEntitiesCallback?: (entityIds: number[], origin?: string) => Promise<ListingEntity[]>;
|
|
95
97
|
ExpandListComponent?: React.ComponentType<{ listing: Listing }> | ((listing: Listing) => JSX.Element) | null;
|
|
96
98
|
}
|
|
97
99
|
|
|
@@ -115,6 +117,7 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
|
|
|
115
117
|
defaultFilters,
|
|
116
118
|
containerStyle,
|
|
117
119
|
ExpandListComponent,
|
|
120
|
+
getListingEntitiesCallback,
|
|
118
121
|
localStorageKey
|
|
119
122
|
}) => {
|
|
120
123
|
const firstLoadFilters = () =>{
|
|
@@ -161,31 +164,31 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
|
|
|
161
164
|
if (!commuteLocation) return;
|
|
162
165
|
|
|
163
166
|
async function fetchEntities() {
|
|
167
|
+
const distinctEntityIds = [
|
|
168
|
+
...new Set(allListings.map(listing => listing.entityId ?? -1))
|
|
169
|
+
];
|
|
164
170
|
try {
|
|
165
|
-
|
|
166
|
-
console.log("
|
|
167
|
-
const fetchedEntities = await
|
|
171
|
+
console.log(getListingEntitiesCallback);
|
|
172
|
+
console.log("fetching entities")
|
|
173
|
+
const fetchedEntities = getListingEntitiesCallback !== null && getListingEntitiesCallback !== undefined ? await getListingEntitiesCallback(distinctEntityIds,
|
|
174
|
+
`${commuteLocation.lat}, ${commuteLocation.lng}`) : await getListingEntities(
|
|
175
|
+
distinctEntityIds,
|
|
168
176
|
`${commuteLocation.lat}, ${commuteLocation.lng}`
|
|
169
177
|
);
|
|
170
|
-
const entitiesByKey = fetchedEntities;
|
|
171
|
-
|
|
172
178
|
setListingEntities(fetchedEntities);
|
|
173
179
|
const newFilteredListings: Listing[] = [...filteredListings] ?? [];
|
|
174
|
-
console.log("Filtered lsitngs:", newFilteredListings);
|
|
175
|
-
console.log("all listings", allListings);
|
|
176
180
|
for (let i = 0; i < allListings.length; i++) {
|
|
177
181
|
const listing = newFilteredListings[i];
|
|
178
182
|
if (
|
|
179
183
|
listing &&
|
|
180
184
|
listing.fields &&
|
|
181
|
-
listing.
|
|
182
|
-
listing.
|
|
185
|
+
listing.entityId !== undefined &&
|
|
186
|
+
listing.entityId !== -1
|
|
183
187
|
) {
|
|
184
|
-
const
|
|
185
|
-
const travelTime =
|
|
186
|
-
|
|
188
|
+
const entityId = listing.entityId;
|
|
189
|
+
const travelTime = fetchedEntities[entityId]?.travelTime;
|
|
190
|
+
|
|
187
191
|
if (travelTime !== undefined && listing.fields) {
|
|
188
|
-
console.log("Setting travel time for listing", travelTime);
|
|
189
192
|
listing.fields.travelTime = travelTime;
|
|
190
193
|
}
|
|
191
194
|
}
|
|
@@ -207,9 +210,9 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
|
|
|
207
210
|
try {
|
|
208
211
|
const {
|
|
209
212
|
listingsResult,
|
|
210
|
-
|
|
213
|
+
fetchedEntities,
|
|
211
214
|
distinctItems
|
|
212
|
-
} = await fetchListings(commuteLocation, entities, listings);
|
|
215
|
+
} = await fetchListings(commuteLocation, entities, listings, getListingEntitiesCallback);
|
|
213
216
|
if (defaultFilters) {
|
|
214
217
|
const filteredListings = listingsResult.filter(listing => {
|
|
215
218
|
if (!listing.fields) return false;
|
|
@@ -224,8 +227,8 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
|
|
|
224
227
|
} else {
|
|
225
228
|
setAllListings(listingsResult);
|
|
226
229
|
}
|
|
227
|
-
setListingEntities(
|
|
228
|
-
setMapItems(
|
|
230
|
+
setListingEntities(fetchedEntities);
|
|
231
|
+
setMapItems(distinctItems);
|
|
229
232
|
} catch (error) {
|
|
230
233
|
console.log(error);
|
|
231
234
|
}
|
|
@@ -266,7 +269,7 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
|
|
|
266
269
|
updateURLWithFilters(tempSelectedFilters, window.location, tempQuery, handleUrlUpdate);
|
|
267
270
|
}
|
|
268
271
|
tempQuery != null ? localStorage.setItem('query', tempQuery) : localStorage.removeItem('query');
|
|
269
|
-
setMapItems(
|
|
272
|
+
setMapItems(mapItems);
|
|
270
273
|
|
|
271
274
|
if (tempSelectedFilters) {
|
|
272
275
|
const keys = Object.keys(tempSelectedFilters);
|
|
@@ -6,47 +6,48 @@ import { ListingEntity } from '~/types/ListingEntity';
|
|
|
6
6
|
|
|
7
7
|
interface FetchListingsResult {
|
|
8
8
|
listingsResult: Listing[];
|
|
9
|
-
|
|
9
|
+
fetchedEntities: Record<number, ListingEntity>;
|
|
10
10
|
distinctItems: any; // Update this type based on the return type of getDistinctItemsByProximity
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const fetchListings = async (
|
|
14
14
|
commuteLocation: any | null = null,
|
|
15
15
|
entities: ListingEntity[] | null,
|
|
16
|
-
listings: Listing[] | null
|
|
16
|
+
listings: Listing[] | null,
|
|
17
|
+
getListingEntitiesCallback?: (entityIds: number[], origin?: string) => Promise<ListingEntity[]>,
|
|
17
18
|
): Promise<FetchListingsResult> => {
|
|
18
19
|
try {
|
|
19
20
|
const listingsResult = listings && listings.length > 0 ? listings : await getListings();
|
|
21
|
+
const distinctEntityIds: number[] = [
|
|
22
|
+
...new Set(listingsResult.map(listing => listing.entityId))
|
|
23
|
+
] as number[];
|
|
20
24
|
|
|
21
25
|
const fetchedEntities = !commuteLocation
|
|
22
|
-
? entities && entities.length > 0 ? entities : await getListingEntities()
|
|
23
|
-
: await getListingEntities(
|
|
26
|
+
? entities && entities.length > 0 ? entities : !getListingEntitiesCallback ? await getListingEntities(distinctEntityIds) : await getListingEntitiesCallback(distinctEntityIds)
|
|
27
|
+
: !getListingEntitiesCallback ? await getListingEntities(
|
|
28
|
+
distinctEntityIds,
|
|
24
29
|
`${commuteLocation.lat}, ${commuteLocation.lng}`
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
//possible quick workaround fix, need to implement clearer code
|
|
28
|
-
|
|
29
|
-
const entitiesByKey = fetchedEntities;
|
|
30
|
+
) : await getListingEntitiesCallback( distinctEntityIds,
|
|
31
|
+
`${commuteLocation.lat}, ${commuteLocation.lng}`);
|
|
30
32
|
for (let i = 0; i < listingsResult.length; i++) {
|
|
31
33
|
const listing = listingsResult[i];
|
|
32
|
-
if (listing.
|
|
33
|
-
const entity =
|
|
34
|
-
console.log("Entity for listing with travel time", listing.fields.entityKey, entity);
|
|
34
|
+
if (listing.entityId && listing.entityId !== -1 && listing.fields) {
|
|
35
|
+
const entity = fetchedEntities[listing.entityId];
|
|
35
36
|
if (entity) {
|
|
36
37
|
listing.fields.travelTime = entity.travelTime;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
|
|
40
42
|
const distinctItems = getDistinctItemsByProximity(
|
|
41
43
|
listingsResult,
|
|
42
|
-
|
|
44
|
+
fetchedEntities
|
|
43
45
|
);
|
|
44
46
|
|
|
45
47
|
return {
|
|
46
48
|
listingsResult,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
distinctItems: distinctItems
|
|
49
|
+
fetchedEntities,
|
|
50
|
+
distinctItems
|
|
50
51
|
};
|
|
51
52
|
} catch (error) {
|
|
52
53
|
console.error("Error fetching listings:", error);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import api from '~/apis/hcApi';
|
|
2
|
+
import { ListingEntity } from '~/types/ListingEntity';
|
|
2
3
|
|
|
3
|
-
export const getListingEntities = async (origin = ''): Promise<
|
|
4
|
+
export const getListingEntities = async (entityIds: number[], origin = ''): Promise<ListingEntity[]> => {
|
|
4
5
|
try {
|
|
5
|
-
|
|
6
|
-
const response = await api.get<any>(`/listingentities/MapEntities?origin=${origin}`);
|
|
6
|
+
const response = await api.post<ListingEntity[]>(`/ListingEntities?origin=${origin}`, entityIds);
|
|
7
7
|
return response;
|
|
8
8
|
} catch (error) {
|
|
9
9
|
console.error("Error fetching listing entities:", error);
|
|
@@ -5,19 +5,18 @@ import { Listing } from '../types/Listings';
|
|
|
5
5
|
|
|
6
6
|
export const getListings = async (params?: GetListingsParams): Promise<Listing[]> => {
|
|
7
7
|
try {
|
|
8
|
-
|
|
8
|
+
const query = new URLSearchParams();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const response = await api.get(`/joblistings/maplistings`);
|
|
10
|
+
if (params) {
|
|
11
|
+
if (params.location) params.location.forEach(loc => query.append('location', loc));
|
|
12
|
+
if (params.category) params.category.forEach(cat => query.append('category', cat));
|
|
13
|
+
if (params.categoryClass) params.categoryClass.forEach(catClass => query.append('categoryClass', catClass));
|
|
14
|
+
if (params.education) params.education.forEach(edu => query.append('education', edu));
|
|
15
|
+
if (params.city) params.city.forEach(cty => query.append('city', cty));
|
|
16
|
+
if (params.state) params.state.forEach(st => query.append('state', st));
|
|
17
|
+
}
|
|
20
18
|
|
|
19
|
+
const response = await api.get(`/Listings?${query.toString()}`);
|
|
21
20
|
return response as Listing[];
|
|
22
21
|
} catch (error) {
|
|
23
22
|
console.error(error);
|
|
@@ -2,10 +2,9 @@ export type ListingFields = {
|
|
|
2
2
|
posted?: string;
|
|
3
3
|
subTitle?: string;
|
|
4
4
|
education?: string;
|
|
5
|
-
|
|
5
|
+
position?: string;
|
|
6
6
|
category?: string;
|
|
7
|
-
|
|
8
|
-
applyUrl?: string;
|
|
7
|
+
categoryClass?: string;
|
|
9
8
|
shift?: string;
|
|
10
9
|
custom1?: string;
|
|
11
10
|
custom2?: string;
|
|
@@ -23,6 +22,5 @@ export type ListingFields = {
|
|
|
23
22
|
useClientJobUrl?: boolean;
|
|
24
23
|
dateCreated: Date;
|
|
25
24
|
dateLastEdited?: Date;
|
|
26
|
-
entityKey: string;
|
|
27
25
|
travelTime?: string;
|
|
28
26
|
}
|
package/src/types/Listings.ts
CHANGED
package/src/util/mapUtil.js
CHANGED
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
export const getDistinctItemsByProximity = (items,
|
|
1
|
+
export const getDistinctItemsByProximity = (items, listingEntitiesDetails) => {
|
|
2
2
|
const clusters = {};
|
|
3
3
|
|
|
4
|
-
if (!
|
|
5
|
-
|
|
6
|
-
const listingEntitiesDetails = Array.isArray(listingEntitiesDetailsInput)
|
|
7
|
-
? listingEntitiesDetailsInput.reduce((acc, entity) => {
|
|
8
|
-
if (entity?.entityKey) acc[entity.entityKey] = entity;
|
|
9
|
-
return acc;
|
|
10
|
-
}, {})
|
|
11
|
-
: listingEntitiesDetailsInput;
|
|
4
|
+
if (!listingEntitiesDetails) return [];
|
|
12
5
|
|
|
13
6
|
const closeItemPairs = findCloseItems(listingEntitiesDetails);
|
|
14
7
|
if (closeItemPairs.length > 0) {
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
listingEntitiesDetails = adjustItemPositions(
|
|
9
|
+
listingEntitiesDetails,
|
|
10
|
+
closeItemPairs
|
|
11
|
+
);
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
items?.forEach(item => {
|
|
20
|
-
|
|
21
|
-
if (!entityKey || entityKey === '-1') return;
|
|
22
|
-
const entityDetails = listingEntitiesDetails[entityKey];
|
|
23
|
-
if (!entityDetails) {
|
|
24
|
-
console.error(`Details not found for entityKey: ${entityKey}`);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
15
|
+
if(item.entityId !== -1){
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
const entityDetails = listingEntitiesDetails[item.entityId];
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
if (!entityDetails) {
|
|
20
|
+
console.error(`Details not found for entityId: ${item.entityId}`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
item.mapDetails = entityDetails;
|
|
25
|
+
|
|
26
|
+
if (!clusters[item.entityId]) {
|
|
27
|
+
clusters[item.entityId] = {
|
|
28
|
+
...item.mapDetails,
|
|
29
|
+
items: { [item.id]: item }
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
clusters[item.entityId].items[item.id] = item;
|
|
33
|
+
}}
|
|
38
34
|
});
|
|
39
35
|
|
|
40
36
|
return Object.values(clusters);
|
|
41
37
|
};
|
|
42
38
|
|
|
43
|
-
export const findCloseItems =
|
|
39
|
+
export const findCloseItems = itemsObj => {
|
|
44
40
|
const closeItems = [];
|
|
45
|
-
const items = Object.values(
|
|
41
|
+
const items = Object.values(itemsObj); // Convert object to array for iteration
|
|
46
42
|
const proximityThreshold = 0.0001;
|
|
47
43
|
|
|
48
44
|
for (let i = 0; i < items.length; i++) {
|
|
49
45
|
for (let j = i + 1; j < items.length; j++) {
|
|
50
46
|
const distanceLat = Math.abs(items[i].latitude - items[j].latitude);
|
|
51
47
|
const distanceLng = Math.abs(items[i].longitude - items[j].longitude);
|
|
52
|
-
if (
|
|
48
|
+
if (
|
|
49
|
+
distanceLat < proximityThreshold &&
|
|
50
|
+
distanceLng < proximityThreshold
|
|
51
|
+
) {
|
|
53
52
|
closeItems.push({ item1: items[i], item2: items[j] });
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -58,18 +57,14 @@ export const findCloseItems = entitiesByKey => {
|
|
|
58
57
|
return closeItems;
|
|
59
58
|
};
|
|
60
59
|
|
|
61
|
-
export const adjustItemPositions = (
|
|
60
|
+
export const adjustItemPositions = (itemsObj, closeItemPairs) => {
|
|
62
61
|
const adjustmentValue = 0.0001;
|
|
63
|
-
const adjustedItems = { ...
|
|
62
|
+
const adjustedItems = { ...itemsObj }; // Create a shallow copy of the object
|
|
64
63
|
|
|
65
64
|
closeItemPairs.forEach(pair => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
adjustedItems[
|
|
69
|
-
...adjustedItems[key2],
|
|
70
|
-
latitude: adjustedItems[key2].latitude + adjustmentValue,
|
|
71
|
-
longitude: adjustedItems[key2].longitude + adjustmentValue
|
|
72
|
-
};
|
|
65
|
+
if (adjustedItems[pair.item1.id] && adjustedItems[pair.item2.id]) {
|
|
66
|
+
adjustedItems[pair.item2.id].latitude += adjustmentValue;
|
|
67
|
+
adjustedItems[pair.item2.id].longitude += adjustmentValue;
|
|
73
68
|
}
|
|
74
69
|
});
|
|
75
70
|
|
|
@@ -79,15 +74,13 @@ export const adjustItemPositions = (entitiesByKey, closeItemPairs) => {
|
|
|
79
74
|
export const clusterOptions = (clusterGridSize, fillColor) => {
|
|
80
75
|
return {
|
|
81
76
|
gridSize: clusterGridSize,
|
|
82
|
-
maxZoom:
|
|
83
|
-
styles:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
]
|
|
77
|
+
maxZoom:15,
|
|
78
|
+
styles:[{
|
|
79
|
+
url: createSvgDataUri(fillColor),
|
|
80
|
+
textColor:'white',
|
|
81
|
+
height: 40,
|
|
82
|
+
width: 40
|
|
83
|
+
}]
|
|
91
84
|
};
|
|
92
85
|
};
|
|
93
86
|
|