From aa893030964a58ad00d38187c90f1d7a9d709ad4 Mon Sep 17 00:00:00 2001 From: Samruddhi <150183547+staware30@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:57:38 -0800 Subject: [PATCH] DXI- 30198 (#185) * Search by ProgramName * filtered based on programName * search field text update --- blocks/gmo-program-header/gmo-program-header.js | 9 +++++---- blocks/gmo-program-list/gmo-program-list.js | 2 +- scripts/graphql.js | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/blocks/gmo-program-header/gmo-program-header.js b/blocks/gmo-program-header/gmo-program-header.js index 00f8cc6..e1edebf 100644 --- a/blocks/gmo-program-header/gmo-program-header.js +++ b/blocks/gmo-program-header/gmo-program-header.js @@ -1,5 +1,6 @@ import { decorateIcons } from '../../scripts/lib-franklin.js'; -import { graphqlCampaignByName } from '../../scripts/graphql.js'; +//import { graphqlCampaignByName } from '../../scripts/graphql.js'; +import { graphqlProgramByName } from '../../scripts/graphql.js'; import { statusMapping, productList, getMappingArray } from '../../scripts/shared-program.js'; export default async function decorate(block) { @@ -7,7 +8,7 @@ export default async function decorate(block) {
- +
@@ -80,9 +81,9 @@ export default async function decorate(block) { const value = this.value; if (value) { - const graphqlData = await graphqlCampaignByName(value); + const graphqlData = await graphqlProgramByName(value); //Get unique values - const searchItems = Array.from(new Set(graphqlData.data.programList.items.map(item => item.campaignName))); + const searchItems = Array.from(new Set(graphqlData.data.programList.items.map(item => item.programName))); autocomplete(value, searchItems); } else diff --git a/blocks/gmo-program-list/gmo-program-list.js b/blocks/gmo-program-list/gmo-program-list.js index 163910c..6a902fb 100644 --- a/blocks/gmo-program-list/gmo-program-list.js +++ b/blocks/gmo-program-list/gmo-program-list.js @@ -57,7 +57,7 @@ document.addEventListener('gmoCampaignListBlock', async function() { const searchInputValue = document.getElementById('campaign-search').value; if (searchInputValue!=='') { - graphQLFilterArray.push({type:'campaignName', value:searchInputValue, operator:'='}) + graphQLFilterArray.push({type:'programName', value:searchInputValue, operator:'='}) } currentGraphqlFilter= generateFilterJSON(graphQLFilterArray); diff --git a/scripts/graphql.js b/scripts/graphql.js index 106d531..37993c1 100644 --- a/scripts/graphql.js +++ b/scripts/graphql.js @@ -83,12 +83,12 @@ export async function graphqlAllCampaignsFilter(first,cursor,filter) { } -export async function graphqlCampaignByName(campaignName) { - const queryName = 'getCampaignNameFilter'; - const encodedCampaignName = encodeURIComponent(campaignName); +export async function graphqlProgramByName(programName) { + const queryName = 'getProgramNameFilter'; + const encodedProgramName = encodeURIComponent(programName); const encodedSemiColon = encodeURIComponent(';'); //persisted query URLs have to be encoded together with the first semicolon - const graphqlEndpoint = `${baseApiUrl}/${projectId}/${queryName}${encodedSemiColon}campaignName=${encodedCampaignName}`; + const graphqlEndpoint = `${baseApiUrl}/${projectId}/${queryName}${encodedSemiColon}programName=${encodedProgramName}`; const jwtToken = await getBearerToken(); // Return the fetch promise chain so that it can be awaited outside