Skip to content

Commit

Permalink
RSVP new expected changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai committed Oct 9, 2024
1 parent 5808dbe commit 2c37c3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions events/blocks/events-form/events-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,14 @@ function showSuccessMsgFirstScreen(bp) {
bp.form.classList.add('hidden');
bp.eventHero.classList.add('hidden');

if (rsvpData?.espProvider?.waitlisted) {
const registrationStatus = rsvpData?.espProvider?.registrationStatus;

if (registrationStatus === 'waitlisted') {
bp.waitlistSuccessScreen.classList.remove('hidden');
bp.waitlistSuccessScreen.querySelector('.first-screen')?.classList.remove('hidden');
}

if (rsvpData?.espProvider?.registered) {
if (registrationStatus === 'registered') {
bp.rsvpSuccessScreen.classList.remove('hidden');
bp.rsvpSuccessScreen.querySelector('.first-screen')?.classList.remove('hidden');
}
Expand Down Expand Up @@ -390,15 +392,15 @@ function decorateSuccessScreen(screen) {
if (cta.classList.contains('cancel-button')) {
const resp = await deleteAttendeeFromEvent(getMetadata('event-id'));
if (!resp.ok) return;

const { data } = resp;

cta.classList.remove('loading');
if (data?.espProvider?.status !== 204) {
buildErrorMsg(bp.successMsg);
buildErrorMsg(screen);
return;
}

if (data?.espProvider?.attendeeDeleted) BlockMediator.set('rsvpData', null);

firstScreen.classList.add('hidden');
Expand Down Expand Up @@ -564,26 +566,24 @@ async function buildEventform(bp, formData) {
}

function initFormBasedOnRSVPData(bp) {
const validRegistrationStatus = ['registered', 'waitlisted'];
const { block } = bp;
const profile = BlockMediator.get('imsProfile');
const rsvpData = BlockMediator.get('rsvpData');
if (rsvpData?.espProvider?.registered
|| rsvpData?.espProvider?.waitlisted
|| rsvpData?.externalAttendeeId) {
if (validRegistrationStatus.includes(rsvpData.espProvider.registrationStatus)) {
showSuccessMsgFirstScreen(bp);
eventFormSendAnalytics(bp, 'Confirmation Modal View');
} else {
personalizeForm(block, profile);
}

BlockMediator.subscribe('rsvpData', ({ newValue }) => {
if (newValue?.espProvider?.registered
|| newValue?.espProvider?.waitlisted
|| newValue?.externalAttendeeId) {
if (validRegistrationStatus.includes(newValue?.espProvider.registrationStatus)) {
showSuccessMsgFirstScreen(bp);
eventFormSendAnalytics(bp, 'Confirmation Modal View');
}
});

if (bp.block.querySelector('.form-success-msg.hidden')) {
eventFormSendAnalytics(bp, 'Form View');
}
Expand Down
4 changes: 2 additions & 2 deletions events/scripts/content-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ async function updateRSVPButtonState(rsvpBtn, miloLibs, eventInfo) {
defaultState();
}
// RSVP data changed by register submission || rsvp data received on page load
} else if (rsvpData.espProvider?.registered || rsvpData.attendeeStatus === 'registered') {
} else if (rsvpData.espProvider?.registrationStatus === 'registered' || rsvpData.attendeeStatus === 'registered') {
await registeredState();
} else if (rsvpData.espProvider?.waitlisted || rsvpData.attendeeStatus === 'waitlisted') {
} else if (rsvpData.espProvider?.registrationStatus === 'waitlisted' || rsvpData.attendeeStatus === 'waitlisted') {
await waitlistedState();
} else if (!rsvpData.ok) {
// FIXME: temporary solution for ESL returning 500 on ESP 400 response
Expand Down

0 comments on commit 2c37c3d

Please sign in to comment.