Skip to content

Commit

Permalink
remove window references, fixed image
Browse files Browse the repository at this point in the history
  • Loading branch information
rrusher committed Jun 11, 2024
1 parent c268419 commit 06f5fa4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
14 changes: 9 additions & 5 deletions blocks/contact-form/contact-form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createOptimizedPicture, loadScript } from '../../scripts/aem.js';
import { loadScript } from '../../scripts/aem.js';
// import { getEnvelope } from '../../scripts/apis/creg/creg.js';
import { removeSideModal, i18nLookup, getCookieValue } from '../../scripts/util.js';
import { a, div } from '../../scripts/dom-helpers.js';
import { a, div, img } from '../../scripts/dom-helpers.js';

const LOGIN_ERROR = 'There was a problem processing your request.';
const i18n = await i18nLookup();
Expand All @@ -15,15 +15,19 @@ function getImageURL(jsonString) {
try {
const data = JSON.parse(jsonString);
if (Array.isArray(data) && data.length > 0) {
const imageUrl = data[0].url;
return imageUrl;
const imageUrl = new URL(data[0].url);
// Replace the hostname and pathname with the new ones
imageUrl.hostname = 'hsfazpw2storagesf1.blob.core.windows.net';
imageUrl.pathname = `/hsflibrary${imageUrl.pathname}`;
return imageUrl.toString();
}
} catch (error) {
return '/media/images/no-profile-image.png';
}
return null; // Add a return statement at the end of the function
}


Check failure on line 30 in blocks/contact-form/contact-form.js

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
/**
* Adds form and cookie values to payload.
*
Expand Down Expand Up @@ -337,7 +341,7 @@ const addForm = async (block) => {
if (prop.propertyDetails.listAgentCd) {
const info = block.querySelector('.contact-info');
const pic = getImageURL(prop.listAgent.reAgentDetail.image);
const profile = div({ class: 'profile' }, createOptimizedPicture(pic, prop.listAgent.recipientName, 'lazy', [{ width: '82' }]));
const profile = div({ class: 'profile' }, img({ src: pic, alt: prop.listAgent.recipientName, width: '82px' }));
info.insertAdjacentElement('beforebegin', profile);
const name = block.querySelector('.company-name');
const link = a({ href: '#' }, prop.listAgent.recipientName); // TODO: add link to agent profile
Expand Down
1 change: 0 additions & 1 deletion blocks/property-listing/property-listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default async function decorate(block) {
const list = div({ class: `property-list-cards rows-${Math.floor(search.pageSize / 8)}` });
block.append(list);
propertySearch(search).then((results) => {
window.propertyListings = results;
renderCards(list, results.properties);
});
}
1 change: 0 additions & 1 deletion blocks/property-search-results/property-search-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ async function doSearch(search, redraw = true) {
const controller = searchController;
propertySearch(search).then((results) => {
if (!controller.signal.aborted) {
window.propertyListings = results;
displayList(parent, results);
contentWrapper.querySelector('.search-results-disclaimer-wrapper').replaceChildren(
domEl('hr', { role: 'presentation', 'aria-hidden': true, tabindex: -1 }),
Expand Down

0 comments on commit 06f5fa4

Please sign in to comment.