Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXI- 30198 #185

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading