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

MWPW-151250: Implemented filtering cards by partner level #14

Merged
merged 15 commits into from
Jun 14, 2024
Merged
Changes from 2 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
31 changes: 29 additions & 2 deletions eds/components/PartnerCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ export class PartnerCards extends LitElement {

const { collectionTags, language, country } = this.blockData;

if (collectionTags) {
api.searchParams.set('collectionTags', collectionTags);
const partnerDataCollectionTag = this.getPartnerDataCollectionTag();
const mergedCollectionTags = collectionTags ? `${collectionTags}&${partnerDataCollectionTag}` : partnerDataCollectionTag;

if (mergedCollectionTags) {
api.searchParams.set('collectionTags', mergedCollectionTags);
}

if (language && country) {
Expand All @@ -209,6 +212,30 @@ export class PartnerCards extends LitElement {
}
}

getPartnerDataCollectionTag () {
try {
let cookies = document.cookie.split(';').map(cookie => cookie.trim());
let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data='));
if (!partnerDataCookie) return '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a public tag to handle this case, but I did not create it yet...

const {level} = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase());
const portal = this.getProgramType(window.location.pathname);
if (!portal || !level) return '';
return `caas:adobe-partners/${portal}/partner-level/${level}`
} catch(error) {
console.error('Error parsing partner data object:', error);
return '';
}
}

getProgramType(path) {
switch(true) {
case /solutionpartners/.test(path): return 'spp';
case /technologypartners/.test(path): return 'tpp';
case /channelpartners/.test(path): return 'cpp';
default: return '';
}
}

initUrlSearchParams () {
const { search } = location || window.location;
this.urlSearchParams = new URLSearchParams(search);
Expand Down
Loading