Skip to content

Commit

Permalink
test fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai committed Oct 29, 2024
1 parent dd0e5db commit b176583
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions events/scripts/content-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ function convertEccIcon(n) {
});
}

function setCtaState(targetState, rsvpBtn, miloLibs, icon = null) {
async function setCtaState(targetState, rsvpBtn, miloLibs) {
const checkRed = getIcon('check-circle-red');
const enableBtn = () => {
rsvpBtn.el.classList.remove('disabled');
rsvpBtn.el.setAttribute('tabindex', 0);
Expand All @@ -87,38 +88,38 @@ function setCtaState(targetState, rsvpBtn, miloLibs, icon = null) {
enableBtn();
updateAnalyticTag(rsvpBtn.el, registeredText);
rsvpBtn.el.textContent = registeredText;
if (icon) rsvpBtn.el.prepend(icon);
rsvpBtn.el.prepend(checkRed);
},
waitlisted: async () => {
const waitlistedText = await miloReplaceKey(miloLibs, 'waitlisted-cta-text');
enableBtn();
updateAnalyticTag(rsvpBtn.el, waitlistedText);
rsvpBtn.el.textContent = waitlistedText;
if (icon) rsvpBtn.el.prepend(icon);
rsvpBtn.el.prepend(checkRed);
},
toWaitlist: async () => {
const waitlistText = await miloReplaceKey(miloLibs, 'waitlist-cta-text');
enableBtn();
updateAnalyticTag(rsvpBtn.el, waitlistText);
rsvpBtn.el.textContent = waitlistText;
icon?.remove();
checkRed.remove();
},
eventClosed: async () => {
const closedText = await miloReplaceKey(miloLibs, 'event-full-cta-text');
disableBtn();
updateAnalyticTag(rsvpBtn.el, closedText);
rsvpBtn.el.textContent = closedText;
icon?.remove();
checkRed.remove();
},
default: async () => {
enableBtn();
updateAnalyticTag(rsvpBtn.el, rsvpBtn.originalText);
rsvpBtn.el.textContent = rsvpBtn.originalText;
icon?.remove();
checkRed.remove();
},
};

stateTrigger[targetState]();
await stateTrigger[targetState]();
}

function createTag(tag, attributes, html, options = {}) {
Expand Down Expand Up @@ -146,7 +147,6 @@ function createTag(tag, attributes, html, options = {}) {
export async function updateRSVPButtonState(rsvpBtn, miloLibs) {
const rsvpData = BlockMediator.get('rsvpData');
const eventInfo = BlockMediator.get('eventData');
const checkRed = getIcon('check-circle-red');
let eventFull = false;
let allowWaitlisting = getMetadata('allow-wait-listing') === 'true';

Expand All @@ -158,17 +158,17 @@ export async function updateRSVPButtonState(rsvpBtn, miloLibs) {
if (!rsvpData) {
if (eventFull) {
if (allowWaitlisting) {
await setCtaState('toWaitlist', rsvpBtn, miloLibs, checkRed);
await setCtaState('toWaitlist', rsvpBtn, miloLibs);
} else {
await setCtaState('eventClosed', rsvpBtn, miloLibs, checkRed);
await setCtaState('eventClosed', rsvpBtn, miloLibs);
}
} else {
await setCtaState('default', rsvpBtn, miloLibs);
}
} else if (rsvpData.registrationStatus === 'registered') {
await setCtaState('registered', rsvpBtn, miloLibs, checkRed);
await setCtaState('registered', rsvpBtn, miloLibs);
} else if (rsvpData.registrationStatus === 'waitlisted') {
await setCtaState('waitlisted', rsvpBtn, miloLibs, checkRed);
await setCtaState('waitlisted', rsvpBtn, miloLibs);
}
}

Expand Down

0 comments on commit b176583

Please sign in to comment.