Skip to content

Commit

Permalink
DXI- 30198 (#185)
Browse files Browse the repository at this point in the history
* Search by ProgramName

* filtered based on programName

* search field text update
  • Loading branch information
staware30 authored Dec 2, 2024
1 parent 8ef73d8 commit aa89303
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions blocks/gmo-program-header/gmo-program-header.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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) {
block.innerHTML = `
<div class="inputs-wrapper">
<div class="search-wrapper">
<span class="icon icon-search"></span>
<input id="campaign-search" maxlength="512" type="search" class="campaign-search" placeholder="Search Marketing Moments...">
<input id="campaign-search" maxlength="512" type="search" class="campaign-search" placeholder="Search by Program Name...">
<!-- autocomplete feature-->
<div id="autocomplete-list" class="autocomplete-items"></div>
</div>
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion blocks/gmo-program-list/gmo-program-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions scripts/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa89303

Please sign in to comment.