Skip to content

Commit

Permalink
Update property-listing.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kailasnadh790 committed May 23, 2024
1 parent 933b7ca commit 3b8441b
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions blocks/property-listing/property-listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export default async function decorate(block) {
} else {
block.innerHTML = '';
}
const user = await getUserDetails();
if (!user) {
return;
}
const { contactKey } = user;

const search = await Search.fromBlockConfig(config);
search.franchiseeCode = getMetadata('office-id');
Expand All @@ -36,22 +41,15 @@ export default async function decorate(block) {
block.append(list);
propertySearch(search).then((results) => {
renderCards(list, results.properties);
});

const user = await getUserDetails();
if (!user) {
return;
}
const { contactKey } = user;

getSavedProperties(contactKey).then((results) => {
if (results?.properties) {
results.properties.forEach((listing) => {
const card = block.querySelector(`[data-id="${listing.PropId}"]`);
if (card) {
card.classList.add('saved');
}
});
}
getSavedProperties(contactKey).then((savedProps) => {
if (savedProps?.properties) {
savedProps.properties.forEach((listing) => {
const card = block.querySelector(`[data-id="${listing.PropId}"]`);
if (card) {
card.classList.add('saved');
}
});
}
});
});
}

0 comments on commit 3b8441b

Please sign in to comment.