Skip to content

Commit

Permalink
Merge pull request #27 from adobecom/mwpw-154955-multiple-regions-tag
Browse files Browse the repository at this point in the history
MWPW-154955 - region tag based on multiple regions account
  • Loading branch information
draganatrajkovic authored Jul 24, 2024
2 parents fd1c7aa + 4f281d3 commit 78e8592
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions edsdme/components/PartnerCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,26 +219,37 @@ export default class PartnerCards extends LitElement {

const partnerLevelParams = this.getPartnerLevelParams(portal);
const partnerRegionParams = this.getPartnerRegionParams(portal);
const collectionTagsStr = this.collectionTags.filter((e) => e.length).join('+AND+');

let collectionTagsStr = this.collectionTags.filter((e) => e.length).join('+AND+');
collectionTagsStr = partnerRegionParams ? `((${collectionTagsStr}+AND+${partnerRegionParams}))` : `((${collectionTagsStr}))`;

let resulStr = `(${collectionTagsStr})`;
if (partnerRegionParams) resulStr += `+AND+${partnerRegionParams}`;
if (partnerLevelParams) resulStr += `+AND+${partnerLevelParams}`;
// eslint-disable-next-line consistent-return
return partnerLevelParams ? `${collectionTagsStr}+AND+${partnerLevelParams}` : collectionTagsStr;
return resulStr;
}

// eslint-disable-next-line class-methods-use-this
getPartnerLevelParams(portal) {
const partnerLevel = getPartnerDataCookieValue(portal, 'level');
const baseTag = `("caas:adobe-partners/${portal}/partner-level/`;
return partnerLevel ? `(${baseTag}${partnerLevel}")+OR+${baseTag}public"))` : `(${baseTag}public"))`;
const partnerTagBase = `"caas:adobe-partners/${portal}/partner-level/`;
return partnerLevel ? `(${partnerTagBase}${partnerLevel}"+OR+${partnerTagBase}public")` : `(${partnerTagBase}public")`;
}

// eslint-disable-next-line class-methods-use-this
getPartnerRegionParams(portal) {
const permisionRegion = getPartnerDataCookieValue(portal, 'permissionregion');
const region = permisionRegion ? permisionRegion.trim().replaceAll(' ', '-') : 'worldwide';
return `"caas:adobe-partners/${portal}/region/${region}"`;
const permissionRegion = getPartnerDataCookieValue(portal, 'permissionregion');
const regionTagBase = `"caas:adobe-partners/${portal}/region/`;

if (!permissionRegion) return `(${regionTagBase}worldwide")`;

const regionTags = [];

permissionRegion.split(',').forEach((region) => {
const regionValue = region.trim().replaceAll(' ', '-');
if (regionValue) regionTags.push(`${regionTagBase}${regionValue}"`);
});

return regionTags.length ? `(${regionTags.join('+OR+')})` : `(${regionTagBase}worldwide")`;
}

initUrlSearchParams() {
Expand Down

0 comments on commit 78e8592

Please sign in to comment.