@abcagency/hc-ui-components 1.4.5 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/components/containers/accordions/map-accordion-item-container.js +1 -3
  2. package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
  3. package/dist/components/containers/maps/info-window-content-container.js.map +1 -1
  4. package/dist/components/containers/maps/map-container.js +1 -0
  5. package/dist/components/containers/maps/map-container.js.map +1 -1
  6. package/dist/components/modules/buttons/button-group-apply.js +4 -4
  7. package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
  8. package/dist/contexts/mapListContext.js +13 -17
  9. package/dist/contexts/mapListContext.js.map +1 -1
  10. package/dist/services/listingAggregatorService.js +10 -11
  11. package/dist/services/listingAggregatorService.js.map +1 -1
  12. package/dist/services/listingEntityService.js +2 -3
  13. package/dist/services/listingEntityService.js.map +1 -1
  14. package/dist/services/listingService.js +16 -10
  15. package/dist/services/listingService.js.map +1 -1
  16. package/dist/types/contexts/mapListContext.d.ts +1 -0
  17. package/dist/types/services/listingAggregatorService.d.ts +1 -1
  18. package/dist/types/services/listingEntityService.d.ts +3 -2
  19. package/dist/types/types/ListingEntity.d.ts +1 -2
  20. package/dist/types/types/ListingFields.d.ts +2 -4
  21. package/dist/types/types/Listings.d.ts +1 -0
  22. package/dist/types/util/mapUtil.d.ts +3 -3
  23. package/dist/util/mapUtil.js +25 -33
  24. package/dist/util/mapUtil.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/components/containers/accordions/map-accordion-item-container.js +1 -3
  27. package/src/components/containers/maps/info-window-content-container.js +1 -1
  28. package/src/components/containers/maps/map-container.js +1 -2
  29. package/src/components/modules/buttons/button-group-apply.js +4 -4
  30. package/src/contexts/mapListContext.tsx +17 -17
  31. package/src/services/listingAggregatorService.ts +12 -13
  32. package/src/services/listingEntityService.ts +3 -3
  33. package/src/services/listingService.ts +10 -11
  34. package/src/types/ListingEntity.ts +1 -2
  35. package/src/types/ListingFields.ts +2 -4
  36. package/src/types/Listings.ts +1 -0
  37. package/src/util/mapUtil.js +41 -48
@@ -1,55 +1,54 @@
1
- export const getDistinctItemsByProximity = (items, listingEntitiesDetailsInput) => {
1
+ export const getDistinctItemsByProximity = (items, listingEntitiesDetails) => {
2
2
  const clusters = {};
3
3
 
4
- if (!listingEntitiesDetailsInput) return [];
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
- const adjusted = adjustItemPositions(listingEntitiesDetails, closeItemPairs);
16
- Object.assign(listingEntitiesDetails, adjusted);
8
+ listingEntitiesDetails = adjustItemPositions(
9
+ listingEntitiesDetails,
10
+ closeItemPairs
11
+ );
17
12
  }
18
13
 
19
14
  items?.forEach(item => {
20
- const entityKey = item?.fields?.entityKey;
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
- item.mapDetails = entityDetails;
17
+ const entityDetails = listingEntitiesDetails[item.entityId];
29
18
 
30
- if (!clusters[entityKey]) {
31
- clusters[entityKey] = {
32
- ...entityDetails,
33
- items: { [item.id]: item }
34
- };
35
- } else {
36
- clusters[entityKey].items[item.id] = item;
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 = entitiesByKey => {
39
+ export const findCloseItems = itemsObj => {
44
40
  const closeItems = [];
45
- const items = Object.values(entitiesByKey); // Convert object to array
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 (distanceLat < proximityThreshold && distanceLng < proximityThreshold) {
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 = (entitiesByKey, closeItemPairs) => {
60
+ export const adjustItemPositions = (itemsObj, closeItemPairs) => {
62
61
  const adjustmentValue = 0.0001;
63
- const adjustedItems = { ...entitiesByKey };
62
+ const adjustedItems = { ...itemsObj }; // Create a shallow copy of the object
64
63
 
65
64
  closeItemPairs.forEach(pair => {
66
- const key2 = pair.item2.entityKey;
67
- if (adjustedItems[key2]) {
68
- adjustedItems[key2] = {
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: 15,
83
- styles: [
84
- {
85
- url: createSvgDataUri(fillColor),
86
- textColor: 'white',
87
- height: 40,
88
- width: 40
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