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-155391: Swap footer logic #38

Merged
merged 2 commits into from
Aug 12, 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
3 changes: 3 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
};
7 changes: 6 additions & 1 deletion edsdme/scripts/scripts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setLibs, redirectLoggedinPartner, updateIMSConfig, preloadResources, getRenewBanner } from './utils.js';
import { setLibs, redirectLoggedinPartner, updateIMSConfig, preloadResources, getRenewBanner, updateFooter } from './utils.js';

// Add project-wide style path here.
const STYLES = '/edsdme/styles/styles.css';
Expand Down Expand Up @@ -71,7 +71,12 @@ const miloLibs = setLibs(LIBS);
});
}());

function setUpPage() {
updateFooter(CONFIG.locales);
}

(async function loadPage() {
setUpPage();
redirectLoggedinPartner();
updateIMSConfig();
await preloadResources(CONFIG.locales, miloLibs);
Expand Down
13 changes: 13 additions & 0 deletions edsdme/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export function getMetadataContent(name) {
return document.querySelector(`meta[name="${name}"]`)?.content;
}

export function getMetadata(name) {
return document.querySelector(`meta[name="${name}"]`);
}

export function redirectLoggedinPartner() {
if (!isMember()) return;
const target = getMetadataContent('adobe-target-after-login');
Expand Down Expand Up @@ -352,3 +356,12 @@ export async function preloadResources(locales, miloLibs) {
preload(caasUrl);
});
}

export function updateFooter(locales) {
const { prefix } = getLocale(locales);
const footerMeta = getMetadata('footer-source');
if (!footerMeta || !isMember()) return;

const footerLoggedIn = getMetadataContent('footer-loggedin-source');
footerMeta.content = footerLoggedIn ?? `${prefix}/edsdme/partners-shared/loggedin-footer`;
}
Loading
Loading