diff --git a/blocks/gmo-program-details/gmo-program-details.js b/blocks/gmo-program-details/gmo-program-details.js index 8feafeb6..09f34aca 100644 --- a/blocks/gmo-program-details/gmo-program-details.js +++ b/blocks/gmo-program-details/gmo-program-details.js @@ -54,7 +54,7 @@ export default async function decorate(block) { decorateIcons(block); } else - { + { //programName and campaignName is null block.innerHTML = `
- ` + `; + try { + //programName and campaignName is null display under development icon + imageObject = await searchAsset(null, null); + if (imageObject) { + insertImageIntoCampaignImg(block, imageObject); + totalassets = imageObject.assetCount; + } + } catch (error) { + console.error("Failed to load campaign image:", error); + } + decorateIcons(block); enableBackBtn(block, blockConfig); return; diff --git a/scripts/assets.js b/scripts/assets.js index ea159d72..7d213422 100644 --- a/scripts/assets.js +++ b/scripts/assets.js @@ -33,6 +33,12 @@ const getFilters = () => { return `is_pur-expirationDate = 0 OR pur-expirationDate > ${currentEpoch}`; }; +async function getUnderdevelopmentIcon() { + const configPath = getBaseConfigPath(); + const brandingConfig = await getBrandingConfig(); + const underdevelopmentIconPath = `${configPath}/${brandingConfig.underdevelopmentIcon}`.replace(/\/\//g, '/'); + return { imageUrl: underdevelopmentIconPath, imageAltText: 'Under Development', assetCount: 0 }; +} /** * Search Asset for programName and campaignName parameters. @@ -49,6 +55,13 @@ export async function searchAsset(programName, campaignName, imageWidth = 80) { const indexName = await getSearchIndex(); + + if (programName==null && campaignName==null) + { + // Display Underdevelopment Icon + return await getUnderdevelopmentIcon(); + } + // Initialize the facetFilters array const facetFilters = []; if (programName) { // Check if programName is not null @@ -96,11 +109,8 @@ export async function searchAsset(programName, campaignName, imageWidth = 80) { } else { - //Display Underdevelopment Icon - const configPath = getBaseConfigPath(); - const brandingConfig = await getBrandingConfig(); - const underdevelopmentIconPath = `${configPath}/${brandingConfig.underdevelopmentIcon}`.replace(/\/\//g, '/'); - return {imageUrl : underdevelopmentIconPath, imageAltText: 'Under Development', assetCount: 0}; + // Display Underdevelopment Icon + return await getUnderdevelopmentIcon(); } } // Handle other response codes @@ -110,3 +120,4 @@ export async function searchAsset(programName, campaignName, imageWidth = 80) { throw error; } } +