Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-155385-personalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
zagi25 committed Aug 15, 2024
2 parents b8371e6 + 6372409 commit b0192a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run-nala-on-dme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ jobs:
prBaseBranch: ${{ github.event.pull_request.base.ref }}
IMS_EMAIL: ${{ secrets.IMS_EMAIL }}
IMS_PASS: ${{ secrets.IMS_PASS }}
HLX_API_KEY: ${{ secrets.HLX_API_KEY }}
37 changes: 18 additions & 19 deletions edsdme/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ export function redirectLoggedinPartner() {

export async function getRenewBanner(getConfig, loadBlock) {
const programType = getCurrentProgramType();

const primaryContact = getPartnerDataCookieValue(programType, 'primarycontact');
if (!primaryContact) return;

const partnerLevel = getPartnerDataCookieValue(programType, 'level');
if (partnerLevel !== 'gold' && partnerLevel !== 'registered' && partnerLevel !== 'certified') return;

const accountExpiration = getPartnerDataCookieValue(programType, 'accountanniversary');
if (!accountExpiration) return;

Expand All @@ -169,22 +176,14 @@ export async function getRenewBanner(getConfig, loadBlock) {
const differenceInDays = Math.abs(differenceInMilliseconds) / (1000 * 60 * 60 * 24);
const differenceInDaysRounded = Math.floor(differenceInDays);

if (differenceInMilliseconds > 0) {
if (differenceInDaysRounded === 0) {
metadataKey = 'banner-account-expires-today';
} else if (differenceInDays < 30) {
metadataKey = 'banner-account-expires';
daysNum = differenceInDaysRounded;
} else {
return;
}
} else if (differenceInMilliseconds < 0) {
if (differenceInDays < 90) {
metadataKey = 'banner-account-suspended';
daysNum = 90 - differenceInDaysRounded;
} else {
return;
}
if (differenceInMilliseconds > 0 && differenceInDays < 31) {
metadataKey = 'banner-account-expires';
daysNum = differenceInDaysRounded;
} else if (differenceInMilliseconds < 0 && differenceInDays <= 90) {
metadataKey = 'banner-account-suspended';
daysNum = 90 - differenceInDaysRounded;
} else {
return;
}

const config = getConfig();
Expand All @@ -198,7 +197,7 @@ export async function getRenewBanner(getConfig, loadBlock) {
if (!response.ok) throw new Error(`Network response was not ok ${response.statusText}`);

const data = await response.text();
const componentData = daysNum ? data.replace('$daysNum', daysNum) : data;
const componentData = data.replace('$daysNum', daysNum);
const parser = new DOMParser();
const doc = parser.parseFromString(componentData, 'text/html');
const aside = doc.querySelector('.aside');
Expand All @@ -207,7 +206,7 @@ export async function getRenewBanner(getConfig, loadBlock) {
const div = document.createElement('div');
div.style.position = 'sticky';
div.style.top = '64px';
div.style.zIndex = 10;
div.style.zIndex = 1;

await loadBlock(aside);
div.appendChild(aside);
Expand Down Expand Up @@ -361,7 +360,7 @@ function getPartnerRegionParams(portal) {

export async function preloadResources(locales, miloLibs) {
const locale = getLocale(locales);
const cardBlocks = { 'announcements': '"caas:adobe-partners/collections/announcements"' };
const cardBlocks = { announcements: '"caas:adobe-partners/collections/announcements"' };

Object.entries(cardBlocks).forEach(async ([key, value]) => {
const el = document.querySelector(`.${key}`);
Expand Down

0 comments on commit b0192a9

Please sign in to comment.