@abcagency/hc-ui-components 1.4.4 → 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 (39) hide show
  1. package/dist/apis/hcApi.js +1 -1
  2. package/dist/apis/hcApi.js.map +1 -1
  3. package/dist/components/containers/accordions/map-accordion-item-container.js +1 -3
  4. package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
  5. package/dist/components/containers/maps/info-window-content-container.js.map +1 -1
  6. package/dist/components/containers/maps/map-container.js +1 -0
  7. package/dist/components/containers/maps/map-container.js.map +1 -1
  8. package/dist/components/modules/buttons/button-group-apply.js +4 -4
  9. package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
  10. package/dist/contexts/mapListContext.js +13 -17
  11. package/dist/contexts/mapListContext.js.map +1 -1
  12. package/dist/services/listingAggregatorService.js +10 -11
  13. package/dist/services/listingAggregatorService.js.map +1 -1
  14. package/dist/services/listingEntityService.js +2 -3
  15. package/dist/services/listingEntityService.js.map +1 -1
  16. package/dist/services/listingService.js +16 -10
  17. package/dist/services/listingService.js.map +1 -1
  18. package/dist/types/contexts/mapListContext.d.ts +1 -0
  19. package/dist/types/services/listingAggregatorService.d.ts +1 -1
  20. package/dist/types/services/listingEntityService.d.ts +3 -2
  21. package/dist/types/types/ListingEntity.d.ts +1 -2
  22. package/dist/types/types/ListingFields.d.ts +2 -4
  23. package/dist/types/types/Listings.d.ts +1 -0
  24. package/dist/types/util/mapUtil.d.ts +3 -3
  25. package/dist/util/mapUtil.js +25 -33
  26. package/dist/util/mapUtil.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/components/containers/accordions/map-accordion-item-container.js +1 -3
  29. package/src/components/containers/maps/info-window-content-container.js +1 -1
  30. package/src/components/containers/maps/map-container.js +1 -2
  31. package/src/components/modules/buttons/button-group-apply.js +4 -4
  32. package/src/contexts/mapListContext.tsx +17 -17
  33. package/src/services/listingAggregatorService.ts +12 -13
  34. package/src/services/listingEntityService.ts +3 -3
  35. package/src/services/listingService.ts +10 -11
  36. package/src/types/ListingEntity.ts +1 -2
  37. package/src/types/ListingFields.ts +2 -4
  38. package/src/types/Listings.ts +1 -0
  39. package/src/util/mapUtil.js +41 -48
@@ -1,9 +1,8 @@
1
1
  import api from '../apis/hcApi.js';
2
2
 
3
- const getListingEntities = async (origin = '') => {
3
+ const getListingEntities = async (entityIds, origin = '') => {
4
4
  try {
5
- //need to update / or add better endpoint fo this to match original functioanlity
6
- const response = await api.get(`/listingentities/MapEntities?origin=${origin}`);
5
+ const response = await api.post(`/ListingEntities?origin=${origin}`, entityIds);
7
6
  return response;
8
7
  }
9
8
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"listingEntityService.js","sources":["../../src/services/listingEntityService.ts"],"sourcesContent":["import api from '~/apis/hcApi';\n\nexport const getListingEntities = async (origin = ''): Promise<any> => {\n\ttry {\n\t\t//need to update / or add better endpoint fo this to match original functioanlity\n\t\tconst response = await api.get<any>(`/listingentities/MapEntities?origin=${origin}`);\n\t\treturn response;\n\t} catch (error) {\n\t\tconsole.error(\"Error fetching listing entities:\", error);\n\t\tthrow error;\n\t}\n};\n\nexport default {\n\tgetListingEntities\n};\n"],"names":[],"mappings":";;AAEa,MAAA,kBAAkB,GAAG,OAAO,MAAM,GAAG,EAAE,KAAkB;IACrE,IAAI;;QAEH,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAAM,CAAuC,oCAAA,EAAA,MAAM,CAAE,CAAA,CAAC,CAAC;AACrF,QAAA,OAAO,QAAQ,CAAC;AAChB,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACf,QAAA,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AACzD,QAAA,MAAM,KAAK,CAAC;AACZ,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"listingEntityService.js","sources":["../../src/services/listingEntityService.ts"],"sourcesContent":["import api from '~/apis/hcApi';\nimport { ListingEntity } from '~/types/ListingEntity';\n\nexport const getListingEntities = async (entityIds: number[], origin = ''): Promise<ListingEntity[]> => {\n\ttry {\n\t\tconst response = await api.post<ListingEntity[]>(`/ListingEntities?origin=${origin}`, entityIds);\n\t\treturn response;\n\t} catch (error) {\n\t\tconsole.error(\"Error fetching listing entities:\", error);\n\t\tthrow error;\n\t}\n};\n\nexport default {\n\tgetListingEntities\n};\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAkB,GAAG,OAAO,SAAmB,EAAE,MAAM,GAAG,EAAE,KAA8B;IACtG,IAAI;AACH,QAAA,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,CAAkB,CAAA,wBAAA,EAA2B,MAAM,CAAA,CAAE,EAAE,SAAS,CAAC,CAAC;AACjG,QAAA,OAAO,QAAQ,CAAC;AAChB,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACf,QAAA,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AACzD,QAAA,MAAM,KAAK,CAAC;AACZ,KAAA;AACF;;;;"}
@@ -2,16 +2,22 @@ import api from '../apis/hcApi.js';
2
2
 
3
3
  const getListings = async (params) => {
4
4
  try {
5
- // const query = new URLSearchParams();
6
- // if (params) {
7
- // if (params.location) params.location.forEach(loc => query.append('location', loc));
8
- // if (params.category) params.category.forEach(cat => query.append('category', cat));
9
- // if (params.categoryClass) params.categoryClass.forEach(catClass => query.append('categoryClass', catClass));
10
- // if (params.education) params.education.forEach(edu => query.append('education', edu));
11
- // if (params.city) params.city.forEach(cty => query.append('city', cty));
12
- // if (params.state) params.state.forEach(st => query.append('state', st));
13
- // }
14
- const response = await api.get(`/joblistings/maplistings`);
5
+ const query = new URLSearchParams();
6
+ if (params) {
7
+ if (params.location)
8
+ params.location.forEach(loc => query.append('location', loc));
9
+ if (params.category)
10
+ params.category.forEach(cat => query.append('category', cat));
11
+ if (params.categoryClass)
12
+ params.categoryClass.forEach(catClass => query.append('categoryClass', catClass));
13
+ if (params.education)
14
+ params.education.forEach(edu => query.append('education', edu));
15
+ if (params.city)
16
+ params.city.forEach(cty => query.append('city', cty));
17
+ if (params.state)
18
+ params.state.forEach(st => query.append('state', st));
19
+ }
20
+ const response = await api.get(`/Listings?${query.toString()}`);
15
21
  return response;
16
22
  }
17
23
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"listingService.js","sources":["../../src/services/listingService.ts"],"sourcesContent":["// listingService.ts\nimport { GetListingsParams } from '~/types/GetListingParams';\nimport api from '../apis/hcApi';\nimport { Listing } from '../types/Listings';\n\nexport const getListings = async (params?: GetListingsParams): Promise<Listing[]> => {\n\ttry {\n\t\t// const query = new URLSearchParams();\n\n\t\t// if (params) {\n\t\t// \tif (params.location) params.location.forEach(loc => query.append('location', loc));\n\t\t// \tif (params.category) params.category.forEach(cat => query.append('category', cat));\n\t\t// \tif (params.categoryClass) params.categoryClass.forEach(catClass => query.append('categoryClass', catClass));\n\t\t// \tif (params.education) params.education.forEach(edu => query.append('education', edu));\n\t\t// \tif (params.city) params.city.forEach(cty => query.append('city', cty));\n\t\t// \tif (params.state) params.state.forEach(st => query.append('state', st));\n\t\t// }\n\n\t\tconst response = await api.get(`/joblistings/maplistings`);\n\n\t\treturn response as Listing[];\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tthrow error;\n\t}\n};\n\nexport const getListingDetails = async (listingId: string) => {\n\ttry {\n\t\tconst response = await api.get(`/ListingDetails/${listingId}`);\n\t\treturn response;\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tthrow error;\n\t}\n};\n\nexport default {\n\tgetListings,\n\tgetListingDetails\n};\n"],"names":[],"mappings":";;MAKa,WAAW,GAAG,OAAO,MAA0B,KAAwB;IACnF,IAAI;;;;;;;;;;QAYH,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,CAA0B,wBAAA,CAAA,CAAC,CAAC;AAE3D,QAAA,OAAO,QAAqB,CAAC;AAC7B,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACf,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrB,QAAA,MAAM,KAAK,CAAC;AACZ,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"listingService.js","sources":["../../src/services/listingService.ts"],"sourcesContent":["// listingService.ts\nimport { GetListingsParams } from '~/types/GetListingParams';\nimport api from '../apis/hcApi';\nimport { Listing } from '../types/Listings';\n\nexport const getListings = async (params?: GetListingsParams): Promise<Listing[]> => {\n\ttry {\n\t\tconst query = new URLSearchParams();\n\n\t\tif (params) {\n\t\t\tif (params.location) params.location.forEach(loc => query.append('location', loc));\n\t\t\tif (params.category) params.category.forEach(cat => query.append('category', cat));\n\t\t\tif (params.categoryClass) params.categoryClass.forEach(catClass => query.append('categoryClass', catClass));\n\t\t\tif (params.education) params.education.forEach(edu => query.append('education', edu));\n\t\t\tif (params.city) params.city.forEach(cty => query.append('city', cty));\n\t\t\tif (params.state) params.state.forEach(st => query.append('state', st));\n\t\t}\n\n\t\tconst response = await api.get(`/Listings?${query.toString()}`);\n\t\treturn response as Listing[];\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tthrow error;\n\t}\n};\n\nexport const getListingDetails = async (listingId: string) => {\n\ttry {\n\t\tconst response = await api.get(`/ListingDetails/${listingId}`);\n\t\treturn response;\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tthrow error;\n\t}\n};\n\nexport default {\n\tgetListings,\n\tgetListingDetails\n};\n"],"names":[],"mappings":";;MAKa,WAAW,GAAG,OAAO,MAA0B,KAAwB;IACnF,IAAI;AACH,QAAA,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;AAEpC,QAAA,IAAI,MAAM,EAAE;YACX,IAAI,MAAM,CAAC,QAAQ;AAAE,gBAAA,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;YACnF,IAAI,MAAM,CAAC,QAAQ;AAAE,gBAAA,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;YACnF,IAAI,MAAM,CAAC,aAAa;AAAE,gBAAA,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC5G,IAAI,MAAM,CAAC,SAAS;AAAE,gBAAA,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;YACtF,IAAI,MAAM,CAAC,IAAI;AAAE,gBAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;YACvE,IAAI,MAAM,CAAC,KAAK;AAAE,gBAAA,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACxE,SAAA;AAED,QAAA,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,CAAa,UAAA,EAAA,KAAK,CAAC,QAAQ,EAAE,CAAA,CAAE,CAAC,CAAC;AAChE,QAAA,OAAO,QAAqB,CAAC;AAC7B,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACf,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrB,QAAA,MAAM,KAAK,CAAC;AACZ,KAAA;AACF;;;;"}
@@ -73,6 +73,7 @@ interface MapListProviderProps {
73
73
  defaultFilters?: Record<string, any>;
74
74
  containerStyle?: any;
75
75
  localStorageKey: string;
76
+ getListingEntitiesCallback?: (entityIds: number[], origin?: string) => Promise<Record<number, ListingEntity>>;
76
77
  ExpandListComponent?: React.ComponentType<{
77
78
  listing: Listing;
78
79
  }> | ((listing: Listing) => JSX.Element) | null;
@@ -2,7 +2,7 @@ import { Listing } from '~/types/Listings';
2
2
  import { ListingEntity } from '~/types/ListingEntity';
3
3
  interface FetchListingsResult {
4
4
  listingsResult: Listing[];
5
- entitiesByKey: Record<string, ListingEntity>;
5
+ fetchedEntities: Record<number, ListingEntity>;
6
6
  distinctItems: any;
7
7
  }
8
8
  declare const fetchListings: (commuteLocation: any | null, entities: ListingEntity[] | null, listings: Listing[] | null) => Promise<FetchListingsResult>;
@@ -1,5 +1,6 @@
1
- export declare const getListingEntities: (origin?: string) => Promise<any>;
1
+ import { ListingEntity } from '~/types/ListingEntity';
2
+ export declare const getListingEntities: (entityIds: number[], origin?: string) => Promise<ListingEntity[]>;
2
3
  declare const _default: {
3
- getListingEntities: (origin?: string) => Promise<any>;
4
+ getListingEntities: (entityIds: number[], origin?: string) => Promise<ListingEntity[]>;
4
5
  };
5
6
  export default _default;
@@ -1,9 +1,8 @@
1
1
  import { Address } from './Address';
2
2
  export type ListingEntity = {
3
- id: string;
3
+ id: number;
4
4
  listingId: number;
5
5
  latitude: number;
6
- entityKey: string;
7
6
  longitude: number;
8
7
  entityDisplayName?: string;
9
8
  address?: Address;
@@ -2,10 +2,9 @@ export type ListingFields = {
2
2
  posted?: string;
3
3
  subTitle?: string;
4
4
  education?: string;
5
- title?: string;
5
+ position?: string;
6
6
  category?: string;
7
- subCategory?: string;
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
  };
@@ -6,6 +6,7 @@ import { SimilarListing } from './SimilarListing';
6
6
  export type Listing = {
7
7
  id: number;
8
8
  fields?: ListingFields;
9
+ entityId?: number;
9
10
  applyUrl?: string;
10
11
  applyOnline?: number;
11
12
  detailsUrl?: string;
@@ -1,9 +1,9 @@
1
- export function getDistinctItemsByProximity(items: any, listingEntitiesDetailsInput: any): any[];
2
- export function findCloseItems(entitiesByKey: any): {
1
+ export function getDistinctItemsByProximity(items: any, listingEntitiesDetails: any): any[];
2
+ export function findCloseItems(itemsObj: any): {
3
3
  item1: any;
4
4
  item2: any;
5
5
  }[];
6
- export function adjustItemPositions(entitiesByKey: any, closeItemPairs: any): any;
6
+ export function adjustItemPositions(itemsObj: any, closeItemPairs: any): any;
7
7
  export function clusterOptions(clusterGridSize: any, fillColor: any): {
8
8
  gridSize: any;
9
9
  maxZoom: number;
@@ -1,40 +1,34 @@
1
1
  import { objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
2
2
 
3
- var getDistinctItemsByProximity = function getDistinctItemsByProximity(items, listingEntitiesDetailsInput) {
3
+ var getDistinctItemsByProximity = function getDistinctItemsByProximity(items, listingEntitiesDetails) {
4
4
  var clusters = {};
5
- if (!listingEntitiesDetailsInput) return [];
6
- var listingEntitiesDetails = Array.isArray(listingEntitiesDetailsInput) ? listingEntitiesDetailsInput.reduce(function (acc, entity) {
7
- if (entity !== null && entity !== void 0 && entity.entityKey) acc[entity.entityKey] = entity;
8
- return acc;
9
- }, {}) : listingEntitiesDetailsInput;
5
+ if (!listingEntitiesDetails) return [];
10
6
  var closeItemPairs = findCloseItems(listingEntitiesDetails);
11
7
  if (closeItemPairs.length > 0) {
12
- var adjusted = adjustItemPositions(listingEntitiesDetails, closeItemPairs);
13
- Object.assign(listingEntitiesDetails, adjusted);
8
+ listingEntitiesDetails = adjustItemPositions(listingEntitiesDetails, closeItemPairs);
14
9
  }
15
10
  items === null || items === void 0 || items.forEach(function (item) {
16
- var _item$fields;
17
- var entityKey = item === null || item === void 0 || (_item$fields = item.fields) === null || _item$fields === void 0 ? void 0 : _item$fields.entityKey;
18
- if (!entityKey || entityKey === '-1') return;
19
- var entityDetails = listingEntitiesDetails[entityKey];
20
- if (!entityDetails) {
21
- console.error("Details not found for entityKey: ".concat(entityKey));
22
- return;
23
- }
24
- item.mapDetails = entityDetails;
25
- if (!clusters[entityKey]) {
26
- clusters[entityKey] = _objectSpread2(_objectSpread2({}, entityDetails), {}, {
27
- items: _defineProperty({}, item.id, item)
28
- });
29
- } else {
30
- clusters[entityKey].items[item.id] = item;
11
+ if (item.entityId !== -1) {
12
+ var entityDetails = listingEntitiesDetails[item.entityId];
13
+ if (!entityDetails) {
14
+ console.error("Details not found for entityId: ".concat(item.entityId));
15
+ return;
16
+ }
17
+ item.mapDetails = entityDetails;
18
+ if (!clusters[item.entityId]) {
19
+ clusters[item.entityId] = _objectSpread2(_objectSpread2({}, item.mapDetails), {}, {
20
+ items: _defineProperty({}, item.id, item)
21
+ });
22
+ } else {
23
+ clusters[item.entityId].items[item.id] = item;
24
+ }
31
25
  }
32
26
  });
33
27
  return Object.values(clusters);
34
28
  };
35
- var findCloseItems = function findCloseItems(entitiesByKey) {
29
+ var findCloseItems = function findCloseItems(itemsObj) {
36
30
  var closeItems = [];
37
- var items = Object.values(entitiesByKey); // Convert object to array
31
+ var items = Object.values(itemsObj); // Convert object to array for iteration
38
32
  var proximityThreshold = 0.0001;
39
33
  for (var i = 0; i < items.length; i++) {
40
34
  for (var j = i + 1; j < items.length; j++) {
@@ -50,16 +44,14 @@ var findCloseItems = function findCloseItems(entitiesByKey) {
50
44
  }
51
45
  return closeItems;
52
46
  };
53
- var adjustItemPositions = function adjustItemPositions(entitiesByKey, closeItemPairs) {
47
+ var adjustItemPositions = function adjustItemPositions(itemsObj, closeItemPairs) {
54
48
  var adjustmentValue = 0.0001;
55
- var adjustedItems = _objectSpread2({}, entitiesByKey);
49
+ var adjustedItems = _objectSpread2({}, itemsObj); // Create a shallow copy of the object
50
+
56
51
  closeItemPairs.forEach(function (pair) {
57
- var key2 = pair.item2.entityKey;
58
- if (adjustedItems[key2]) {
59
- adjustedItems[key2] = _objectSpread2(_objectSpread2({}, adjustedItems[key2]), {}, {
60
- latitude: adjustedItems[key2].latitude + adjustmentValue,
61
- longitude: adjustedItems[key2].longitude + adjustmentValue
62
- });
52
+ if (adjustedItems[pair.item1.id] && adjustedItems[pair.item2.id]) {
53
+ adjustedItems[pair.item2.id].latitude += adjustmentValue;
54
+ adjustedItems[pair.item2.id].longitude += adjustmentValue;
63
55
  }
64
56
  });
65
57
  return adjustedItems;
@@ -1 +1 @@
1
- {"version":3,"file":"mapUtil.js","sources":["../../src/util/mapUtil.js"],"sourcesContent":["export const getDistinctItemsByProximity = (items, listingEntitiesDetailsInput) => {\n\tconst clusters = {};\n\n\tif (!listingEntitiesDetailsInput) return [];\n\n\tconst listingEntitiesDetails = Array.isArray(listingEntitiesDetailsInput)\n\t\t? listingEntitiesDetailsInput.reduce((acc, entity) => {\n\t\t\tif (entity?.entityKey) acc[entity.entityKey] = entity;\n\t\t\treturn acc;\n\t\t }, {})\n\t\t: listingEntitiesDetailsInput;\n\n\tconst closeItemPairs = findCloseItems(listingEntitiesDetails);\n\tif (closeItemPairs.length > 0) {\n\t\tconst adjusted = adjustItemPositions(listingEntitiesDetails, closeItemPairs);\n\t\tObject.assign(listingEntitiesDetails, adjusted);\n\t}\n\n\titems?.forEach(item => {\n\t\tconst entityKey = item?.fields?.entityKey;\n\t\tif (!entityKey || entityKey === '-1') return;\n\t\tconst entityDetails = listingEntitiesDetails[entityKey];\n\t\tif (!entityDetails) {\n\t\t\tconsole.error(`Details not found for entityKey: ${entityKey}`);\n\t\t\treturn;\n\t\t}\n\n\t\titem.mapDetails = entityDetails;\n\n\t\tif (!clusters[entityKey]) {\n\t\t\tclusters[entityKey] = {\n\t\t\t\t...entityDetails,\n\t\t\t\titems: { [item.id]: item }\n\t\t\t};\n\t\t} else {\n\t\t\tclusters[entityKey].items[item.id] = item;\n\t\t}\n\t});\n\n\treturn Object.values(clusters);\n};\n\nexport const findCloseItems = entitiesByKey => {\n\tconst closeItems = [];\n\tconst items = Object.values(entitiesByKey); // Convert object to array\n\tconst proximityThreshold = 0.0001;\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\tfor (let j = i + 1; j < items.length; j++) {\n\t\t\tconst distanceLat = Math.abs(items[i].latitude - items[j].latitude);\n\t\t\tconst distanceLng = Math.abs(items[i].longitude - items[j].longitude);\n\t\t\tif (distanceLat < proximityThreshold && distanceLng < proximityThreshold) {\n\t\t\t\tcloseItems.push({ item1: items[i], item2: items[j] });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn closeItems;\n};\n\nexport const adjustItemPositions = (entitiesByKey, closeItemPairs) => {\n\tconst adjustmentValue = 0.0001;\n\tconst adjustedItems = { ...entitiesByKey };\n\n\tcloseItemPairs.forEach(pair => {\n\t\tconst key2 = pair.item2.entityKey;\n\t\tif (adjustedItems[key2]) {\n\t\t\tadjustedItems[key2] = {\n\t\t\t\t...adjustedItems[key2],\n\t\t\t\tlatitude: adjustedItems[key2].latitude + adjustmentValue,\n\t\t\t\tlongitude: adjustedItems[key2].longitude + adjustmentValue\n\t\t\t};\n\t\t}\n\t});\n\n\treturn adjustedItems;\n};\n\nexport const clusterOptions = (clusterGridSize, fillColor) => {\n\treturn {\n\t\tgridSize: clusterGridSize,\n\t\tmaxZoom: 15,\n\t\tstyles: [\n\t\t\t{\n\t\t\t\turl: createSvgDataUri(fillColor),\n\t\t\t\ttextColor: 'white',\n\t\t\t\theight: 40,\n\t\t\t\twidth: 40\n\t\t\t}\n\t\t]\n\t};\n};\n\nfunction createSvgDataUri(fillColor) {\n\tconst svg = `<svg width=\"50\" height=\"50\" xmlns=\"http://www.w3.org/2000/svg\">\n\t <circle cx=\"25\" cy=\"25\" r=\"20\" fill=\"${fillColor}\" />\n\t</svg>`;\n\treturn `data:image/svg+xml;base64,${btoa(svg)}`;\n}\n"],"names":["getDistinctItemsByProximity","items","listingEntitiesDetailsInput","clusters","listingEntitiesDetails","Array","isArray","reduce","acc","entity","entityKey","closeItemPairs","findCloseItems","length","adjusted","adjustItemPositions","Object","assign","forEach","item","_item$fields","fields","entityDetails","console","error","concat","mapDetails","_objectSpread","_defineProperty","id","values","entitiesByKey","closeItems","proximityThreshold","i","j","distanceLat","Math","abs","latitude","distanceLng","longitude","push","item1","item2","adjustmentValue","adjustedItems","pair","key2","clusterOptions","clusterGridSize","fillColor","gridSize","maxZoom","styles","url","createSvgDataUri","textColor","height","width","svg","btoa"],"mappings":";;AAAO,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAAIC,KAAK,EAAEC,2BAA2B,EAAK;EAClF,IAAMC,QAAQ,GAAG,EAAE,CAAA;AAEnB,EAAA,IAAI,CAACD,2BAA2B,EAAE,OAAO,EAAE,CAAA;AAE3C,EAAA,IAAME,sBAAsB,GAAGC,KAAK,CAACC,OAAO,CAACJ,2BAA2B,CAAC,GACtEA,2BAA2B,CAACK,MAAM,CAAC,UAACC,GAAG,EAAEC,MAAM,EAAK;AACrD,IAAA,IAAIA,MAAM,KAAA,IAAA,IAANA,MAAM,KAAA,KAAA,CAAA,IAANA,MAAM,CAAEC,SAAS,EAAEF,GAAG,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM,CAAA;AACrD,IAAA,OAAOD,GAAG,CAAA;AACT,GAAC,EAAE,EAAE,CAAC,GACNN,2BAA2B,CAAA;AAE9B,EAAA,IAAMS,cAAc,GAAGC,cAAc,CAACR,sBAAsB,CAAC,CAAA;AAC7D,EAAA,IAAIO,cAAc,CAACE,MAAM,GAAG,CAAC,EAAE;AAC9B,IAAA,IAAMC,QAAQ,GAAGC,mBAAmB,CAACX,sBAAsB,EAAEO,cAAc,CAAC,CAAA;AAC5EK,IAAAA,MAAM,CAACC,MAAM,CAACb,sBAAsB,EAAEU,QAAQ,CAAC,CAAA;AAChD,GAAA;EAEAb,KAAK,KAAA,IAAA,IAALA,KAAK,KAALA,KAAAA,CAAAA,IAAAA,KAAK,CAAEiB,OAAO,CAAC,UAAAC,IAAI,EAAI;AAAA,I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Aa,CAACE,IAAI,CAAC,EAAE;MACxBF,aAAa,CAACE,IAAI,CAAC,GAAArB,cAAA,CAAAA,cAAA,CACfmB,EAAAA,EAAAA,aAAa,CAACE,IAAI,CAAC,CAAA,EAAA,EAAA,EAAA;QACtBT,QAAQ,EAAEO,aAAa,CAACE,IAAI,CAAC,CAACT,QAAQ,GAAGM,eAAe;AACxDJ,QAAAA,SAAS,EAAEK,aAAa,CAACE,IAAI,CAAC,CAACP,SAAS,GAAGI,eAAAA;OAC3C,CAAA,CAAA;AACF,KAAA;AACD,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOC,aAAa,CAAA;AACrB,EAAC;AAEM,IAAMG,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,eAAe,EAAEC,SAAS,EAAK;EAC7D,OAAO;AACNC,IAAAA,QAAQ,EAAEF,eAAe;AACzBG,IAAAA,OAAO,EAAE,EAAE;AACXC,IAAAA,MAAM,EAAE,CACP;AACCC,MAAAA,GAAG,EAAEC,gBAAgB,CAACL,SAAS,CAAC;AAChCM,MAAAA,SAAS,EAAE,OAAO;AAClBC,MAAAA,MAAM,EAAE,EAAE;AACVC,MAAAA,KAAK,EAAE,EAAA;KACP,CAAA;GAEF,CAAA;AACF,EAAC;AAED,SAASH,gBAAgBA,CAACL,SAAS,EAAE;AACpC,EAAA,IAAMS,GAAG,GAAA,yHAAA,CAAAnC,MAAA,CACgC0B,SAAS,EAC3C,iBAAA,CAAA,CAAA;AACP,EAAA,OAAA,4BAAA,CAAA1B,MAAA,CAAoCoC,IAAI,CAACD,GAAG,CAAC,CAAA,CAAA;AAC9C;;;;"}
1
+ {"version":3,"file":"mapUtil.js","sources":["../../src/util/mapUtil.js"],"sourcesContent":["export const getDistinctItemsByProximity = (items, listingEntitiesDetails) => {\n\tconst clusters = {};\n\n\tif (!listingEntitiesDetails) return [];\n\n\tconst closeItemPairs = findCloseItems(listingEntitiesDetails);\n\tif (closeItemPairs.length > 0) {\n\t\tlistingEntitiesDetails = adjustItemPositions(\n\t\t\tlistingEntitiesDetails,\n\t\t\tcloseItemPairs\n\t\t);\n\t}\n\n\titems?.forEach(item => {\n\t\tif(item.entityId !== -1){\n\n\t\t\tconst entityDetails = listingEntitiesDetails[item.entityId];\n\n\t\t\tif (!entityDetails) {\n\t\t\t\tconsole.error(`Details not found for entityId: ${item.entityId}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\titem.mapDetails = entityDetails;\n\n\t\t\tif (!clusters[item.entityId]) {\n\t\t\t\tclusters[item.entityId] = {\n\t\t\t\t\t...item.mapDetails,\n\t\t\t\t\titems: { [item.id]: item }\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tclusters[item.entityId].items[item.id] = item;\n\t\t\t}}\n\t});\n\n\treturn Object.values(clusters);\n};\n\nexport const findCloseItems = itemsObj => {\n\tconst closeItems = [];\n\tconst items = Object.values(itemsObj); // Convert object to array for iteration\n\tconst proximityThreshold = 0.0001;\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\tfor (let j = i + 1; j < items.length; j++) {\n\t\t\tconst distanceLat = Math.abs(items[i].latitude - items[j].latitude);\n\t\t\tconst distanceLng = Math.abs(items[i].longitude - items[j].longitude);\n\t\t\tif (\n\t\t\t\tdistanceLat < proximityThreshold &&\n\t\t\t\tdistanceLng < proximityThreshold\n\t\t\t) {\n\t\t\t\tcloseItems.push({ item1: items[i], item2: items[j] });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn closeItems;\n};\n\nexport const adjustItemPositions = (itemsObj, closeItemPairs) => {\n\tconst adjustmentValue = 0.0001;\n\tconst adjustedItems = { ...itemsObj }; // Create a shallow copy of the object\n\n\tcloseItemPairs.forEach(pair => {\n\t\tif (adjustedItems[pair.item1.id] && adjustedItems[pair.item2.id]) {\n\t\t\tadjustedItems[pair.item2.id].latitude += adjustmentValue;\n\t\t\tadjustedItems[pair.item2.id].longitude += adjustmentValue;\n\t\t}\n\t});\n\n\treturn adjustedItems;\n};\n\nexport const clusterOptions = (clusterGridSize, fillColor) => {\n\treturn {\n\t\tgridSize: clusterGridSize,\n\t\tmaxZoom:15,\n\t\tstyles:[{\n\t\t\turl: createSvgDataUri(fillColor),\n\t\t\ttextColor:'white',\n\t\t\theight: 40,\n\t\t\twidth: 40\n\t\t}]\n\t};\n};\n\nfunction createSvgDataUri(fillColor) {\n\tconst svg = `<svg width=\"50\" height=\"50\" xmlns=\"http://www.w3.org/2000/svg\">\n\t <circle cx=\"25\" cy=\"25\" r=\"20\" fill=\"${fillColor}\" />\n\t</svg>`;\n\treturn `data:image/svg+xml;base64,${btoa(svg)}`;\n}\n"],"names":["getDistinctItemsByProximity","items","listingEntitiesDetails","clusters","closeItemPairs","findCloseItems","length","adjustItemPositions","forEach","item","entityId","entityDetails","console","error","concat","mapDetails","_objectSpread","_defineProperty","id","Object","values","itemsObj","closeItems","proximityThreshold","i","j","distanceLat","Math","abs","latitude","distanceLng","longitude","push","item1","item2","adjustmentValue","adjustedItems","pair","clusterOptions","clusterGridSize","fillColor","gridSize","maxZoom","styles","url","createSvgDataUri","textColor","height","width","svg","btoa"],"mappings":";;AAAO,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAAIC,KAAK,EAAEC,sBAAsB,EAAK;EAC7E,IAAMC,QAAQ,GAAG,EAAE,CAAA;AAEnB,EAAA,IAAI,CAACD,sBAAsB,EAAE,OAAO,EAAE,CAAA;AAEtC,EAAA,IAAME,cAAc,GAAGC,cAAc,CAACH,sBAAsB,CAAC,CAAA;AAC7D,EAAA,IAAIE,cAAc,CAACE,MAAM,GAAG,CAAC,EAAE;AAC9BJ,IAAAA,sBAAsB,GAAGK,mBAAmB,CAC3CL,sBAAsB,EACtBE,cACD,CAAC,CAAA;AACF,GAAA;EAEAH,KAAK,KAAA,IAAA,IAALA,KAAK,KAALA,KAAAA,CAAAA,IAAAA,KAAK,CAAEO,OAAO,CAAC,UAAAC,IAAI,EAAI;AACtB,IAAA,IAAGA,IAAI,CAACC,QAAQ,KAAK,CAAC,CA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AAS,IAAII,eAAe,CAAA;AAC1D,KAAA;AACD,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOC,aAAa,CAAA;AACrB,EAAC;AAEM,IAAME,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,eAAe,EAAEC,SAAS,EAAK;EAC7D,OAAO;AACNC,IAAAA,QAAQ,EAAEF,eAAe;AACzBG,IAAAA,OAAO,EAAC,EAAE;AACVC,IAAAA,MAAM,EAAC,CAAC;AACPC,MAAAA,GAAG,EAAEC,gBAAgB,CAACL,SAAS,CAAC;AAChCM,MAAAA,SAAS,EAAC,OAAO;AACjBC,MAAAA,MAAM,EAAE,EAAE;AACVC,MAAAA,KAAK,EAAE,EAAA;KACP,CAAA;GACD,CAAA;AACF,EAAC;AAED,SAASH,gBAAgBA,CAACL,SAAS,EAAE;AACpC,EAAA,IAAMS,GAAG,GAAA,yHAAA,CAAAnC,MAAA,CACgC0B,SAAS,EAC3C,iBAAA,CAAA,CAAA;AACP,EAAA,OAAA,4BAAA,CAAA1B,MAAA,CAAoCoC,IAAI,CAACD,GAAG,CAAC,CAAA,CAAA;AAC9C;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcagency/hc-ui-components",
3
- "version": "1.4.04",
3
+ "version": "1.4.7",
4
4
  "description": "UI Components for HireControl",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -25,9 +25,7 @@ const MapAccordionItemContainer = ({
25
25
  selectItem(null, null, 9, { lat: 39.8283, lng: -98.5795 });
26
26
  } else {
27
27
  setStorageObject("selectedListItem", item);
28
- console.log('mapItems here', mapItems);
29
- //edited here for new structure of entity key
30
- const location = mapItems.find(x => Object.prototype.hasOwnProperty.call(x.items, item.entityKey)) || null;
28
+ const location = mapItems.find(x => Object.prototype.hasOwnProperty.call(x.items, item.id)) || null;
31
29
  selectItem(item, location, 12, {
32
30
  lat: location?.latitude,
33
31
  lng: location?.longitude
@@ -57,7 +57,7 @@ const InfoWindowContentContainer = ({
57
57
  newFilters.state = { [items[0].fields.state]: true };
58
58
  filters.push({ filterType: 'state', filterChecked: items[0].fields.state });
59
59
  }
60
-
60
+
61
61
  newFilters.entityName = { [items[0].fields.entityName]: true };
62
62
  filters.push({ filterType: 'entityName', filterChecked: items[0].fields.entityName });
63
63
 
@@ -256,10 +256,9 @@ const MapContainer = ({ markerConfigs, infoWindowClasses, clusterGridSize = 60 }
256
256
  if (!mapItems) {
257
257
  return null;
258
258
  }
259
-
260
259
  const mapItemsKey = mapItems.map(item => item.id).join("-");
261
260
 
262
-
261
+ console.log(location);
263
262
  return (
264
263
  <Map
265
264
  zoom={zoom}
@@ -78,9 +78,9 @@ const ButtonGroupApply = ({
78
78
  </Button.Anchor>
79
79
  ) : null}
80
80
 
81
- {item.fields.applyOnline == true && item.fields.applyUrl && !includeDialog &&
81
+ {item.applyOnline == 1 && item.applyUrl && !includeDialog &&
82
82
  <Button.Anchor
83
- href={item.fields.applyUrl}
83
+ href={item.applyUrl}
84
84
  variant={applyButtonVariant}
85
85
  size={buttonSize}
86
86
  className={"map-apply-now-button"}
@@ -91,8 +91,8 @@ const ButtonGroupApply = ({
91
91
  {applyNowText}
92
92
  </Button.Anchor>
93
93
  }
94
- {item.fields.applyOnline == true && item.fields.applyUrl && includeDialog &&
95
- <ApplyDialog applyUrl={item.fields.applyUrl} internalApplyLink={internalApplyLink} companyName={companyName} item={item} trackEvent={trackEvent} eventTypes={eventTypes} isIframe={isIframe}>
94
+ {item.applyOnline == 1 && item.applyUrl && includeDialog &&
95
+ <ApplyDialog applyUrl={item.applyUrl} internalApplyLink={internalApplyLink} companyName={companyName} item={item} trackEvent={trackEvent} eventTypes={eventTypes} isIframe={isIframe}>
96
96
  <Button.Anchor
97
97
  variant={applyButtonVariant}
98
98
  size={buttonSize}
@@ -92,6 +92,7 @@ interface MapListProviderProps {
92
92
  defaultFilters?: Record<string, any>;
93
93
  containerStyle?: any;
94
94
  localStorageKey: string;
95
+ getListingEntitiesCallback?: (entityIds: number[], origin?: string) => Promise<Record<number, ListingEntity>>;
95
96
  ExpandListComponent?: React.ComponentType<{ listing: Listing }> | ((listing: Listing) => JSX.Element) | null;
96
97
  }
97
98
 
@@ -115,6 +116,7 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
115
116
  defaultFilters,
116
117
  containerStyle,
117
118
  ExpandListComponent,
119
+ getListingEntitiesCallback,
118
120
  localStorageKey
119
121
  }) => {
120
122
  const firstLoadFilters = () =>{
@@ -161,31 +163,29 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
161
163
  if (!commuteLocation) return;
162
164
 
163
165
  async function fetchEntities() {
166
+ const distinctEntityIds = [
167
+ ...new Set(allListings.map(listing => listing.entityId ?? -1))
168
+ ];
164
169
  try {
165
- //gonna need to fix this here
166
- console.log("Fetching entities for commute location", commuteLocation);
167
- const fetchedEntities = await getListingEntities(
170
+ const fetchedEntities = getListingEntitiesCallback !== null && getListingEntitiesCallback !== undefined ? await getListingEntitiesCallback(distinctEntityIds,
171
+ `${commuteLocation.lat}, ${commuteLocation.lng}`) : await getListingEntities(
172
+ distinctEntityIds,
168
173
  `${commuteLocation.lat}, ${commuteLocation.lng}`
169
174
  );
170
- const entitiesByKey = fetchedEntities;
171
-
172
175
  setListingEntities(fetchedEntities);
173
176
  const newFilteredListings: Listing[] = [...filteredListings] ?? [];
174
- console.log("Filtered lsitngs:", newFilteredListings);
175
- console.log("all listings", allListings);
176
177
  for (let i = 0; i < allListings.length; i++) {
177
178
  const listing = newFilteredListings[i];
178
179
  if (
179
180
  listing &&
180
181
  listing.fields &&
181
- listing.fields.entityKey !== undefined &&
182
- listing.fields.entityKey !== ''
182
+ listing.entityId !== undefined &&
183
+ listing.entityId !== -1
183
184
  ) {
184
- const entityKey = listing.fields.entityKey;
185
- const travelTime = entitiesByKey[entityKey]?.travelTime;
186
- console.log("Entity for listing with travel time", entityKey, entitiesByKey[entityKey]);
185
+ const entityId = listing.entityId;
186
+ const travelTime = fetchedEntities[entityId]?.travelTime;
187
+
187
188
  if (travelTime !== undefined && listing.fields) {
188
- console.log("Setting travel time for listing", travelTime);
189
189
  listing.fields.travelTime = travelTime;
190
190
  }
191
191
  }
@@ -207,7 +207,7 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
207
207
  try {
208
208
  const {
209
209
  listingsResult,
210
- entitiesByKey,
210
+ fetchedEntities,
211
211
  distinctItems
212
212
  } = await fetchListings(commuteLocation, entities, listings);
213
213
  if (defaultFilters) {
@@ -224,8 +224,8 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
224
224
  } else {
225
225
  setAllListings(listingsResult);
226
226
  }
227
- setListingEntities(entitiesByKey);
228
- setMapItems(Object.values(mapItems));
227
+ setListingEntities(fetchedEntities);
228
+ setMapItems(distinctItems);
229
229
  } catch (error) {
230
230
  console.log(error);
231
231
  }
@@ -266,7 +266,7 @@ export const MapListProvider: React.FC<MapListProviderProps> = ({
266
266
  updateURLWithFilters(tempSelectedFilters, window.location, tempQuery, handleUrlUpdate);
267
267
  }
268
268
  tempQuery != null ? localStorage.setItem('query', tempQuery) : localStorage.removeItem('query');
269
- setMapItems(Object.values(mapItems));
269
+ setMapItems(mapItems);
270
270
 
271
271
  if (tempSelectedFilters) {
272
272
  const keys = Object.keys(tempSelectedFilters);
@@ -6,7 +6,7 @@ import { ListingEntity } from '~/types/ListingEntity';
6
6
 
7
7
  interface FetchListingsResult {
8
8
  listingsResult: Listing[];
9
- entitiesByKey: Record<string, ListingEntity>;
9
+ fetchedEntities: Record<number, ListingEntity>;
10
10
  distinctItems: any; // Update this type based on the return type of getDistinctItemsByProximity
11
11
  }
12
12
 
@@ -17,36 +17,35 @@ const fetchListings = async (
17
17
  ): Promise<FetchListingsResult> => {
18
18
  try {
19
19
  const listingsResult = listings && listings.length > 0 ? listings : await getListings();
20
+ const distinctEntityIds: number[] = [
21
+ ...new Set(listingsResult.map(listing => listing.entityId))
22
+ ] as number[];
20
23
 
21
24
  const fetchedEntities = !commuteLocation
22
- ? entities && entities.length > 0 ? entities : await getListingEntities()
25
+ ? entities && entities.length > 0 ? entities : await getListingEntities(distinctEntityIds)
23
26
  : await getListingEntities(
27
+ distinctEntityIds,
24
28
  `${commuteLocation.lat}, ${commuteLocation.lng}`
25
29
  );
26
-
27
- //possible quick workaround fix, need to implement clearer code
28
-
29
- const entitiesByKey = fetchedEntities;
30
30
  for (let i = 0; i < listingsResult.length; i++) {
31
31
  const listing = listingsResult[i];
32
- if (listing.fields && listing.fields.entityKey && listing.fields.entityKey !== '' && listing.fields) {
33
- const entity = entitiesByKey[listing.fields.entityKey];
34
- console.log("Entity for listing with travel time", listing.fields.entityKey, entity);
32
+ if (listing.entityId && listing.entityId !== -1 && listing.fields) {
33
+ const entity = fetchedEntities[listing.entityId];
35
34
  if (entity) {
36
35
  listing.fields.travelTime = entity.travelTime;
37
36
  }
38
37
  }
39
38
  }
39
+
40
40
  const distinctItems = getDistinctItemsByProximity(
41
41
  listingsResult,
42
- entitiesByKey,
42
+ fetchedEntities
43
43
  );
44
44
 
45
45
  return {
46
46
  listingsResult,
47
- entitiesByKey,
48
- //temp fix, need to fix the proximity function to work with entity key and use
49
- distinctItems: distinctItems
47
+ fetchedEntities,
48
+ distinctItems
50
49
  };
51
50
  } catch (error) {
52
51
  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<any> => {
4
+ export const getListingEntities = async (entityIds: number[], origin = ''): Promise<ListingEntity[]> => {
4
5
  try {
5
- //need to update / or add better endpoint fo this to match original functioanlity
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
- // const query = new URLSearchParams();
8
+ const query = new URLSearchParams();
9
9
 
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
- // }
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);
@@ -1,10 +1,9 @@
1
1
  import { Address } from './Address';
2
2
 
3
3
  export type ListingEntity = {
4
- id: string;
4
+ id: number;
5
5
  listingId: number;
6
6
  latitude: number;
7
- entityKey: string;
8
7
  longitude: number;
9
8
  entityDisplayName?: string;
10
9
  address?: Address;
@@ -2,10 +2,9 @@ export type ListingFields = {
2
2
  posted?: string;
3
3
  subTitle?: string;
4
4
  education?: string;
5
- title?: string;
5
+ position?: string;
6
6
  category?: string;
7
- subCategory?: string;
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
  }
@@ -7,6 +7,7 @@ import { SimilarListing } from './SimilarListing';
7
7
  export type Listing = {
8
8
  id: number;
9
9
  fields?: ListingFields;
10
+ entityId?: number;
10
11
  applyUrl?: string;
11
12
  applyOnline?: number;
12
13
  detailsUrl?: string;