From 2b94c7bfe68750be2e8a35c6f2da29cc07e0ee2c Mon Sep 17 00:00:00 2001 From: Qiyun Dai Date: Thu, 24 Oct 2024 16:17:16 -0500 Subject: [PATCH 1/2] Fix Inaccurate Error Resp during RSVP --- events/blocks/events-form/events-form.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/events/blocks/events-form/events-form.js b/events/blocks/events-form/events-form.js index b2327733..c26f1db8 100644 --- a/events/blocks/events-form/events-form.js +++ b/events/blocks/events-form/events-form.js @@ -172,20 +172,16 @@ function createButton({ type, label }, bp) { if (respJson.ok) { eventFormSendAnalytics(bp, 'Form Submit'); } else { - let { status } = respJson; - - // FIXME: temporary fix for ESL 500 on ESP 400 - if (!status || status === 500) { - if (respJson.error?.message === 'Request to ESP failed: Event is full') { - status = 400; - - const eventResp = await getEvent(getMetadata('event-id')); - if (eventResp.ok && eventResp.data?.isFull) { - button.textContent = await miloReplaceKey(LIBS, 'waitlist-cta-text'); - BlockMediator.set('eventData', eventResp.data); - } + const { status } = respJson; + + if (status === 400 && respJson.error?.message === 'Request to ESP failed: Event is full') { + const eventResp = await getEvent(getMetadata('event-id')); + if (eventResp.ok && eventResp.data?.isFull) { + button.textContent = await miloReplaceKey(LIBS, 'waitlist-cta-text'); + BlockMediator.set('eventData', eventResp.data); } } + buildErrorMsg(bp.form, status); } } From 7a4dca40535578aeedab996d87f493dba6a242d1 Mon Sep 17 00:00:00 2001 From: Qiyun Dai Date: Thu, 24 Oct 2024 16:22:48 -0500 Subject: [PATCH 2/2] Update events-form.js --- events/blocks/events-form/events-form.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/events/blocks/events-form/events-form.js b/events/blocks/events-form/events-form.js index c26f1db8..28c458de 100644 --- a/events/blocks/events-form/events-form.js +++ b/events/blocks/events-form/events-form.js @@ -399,13 +399,18 @@ function decorateSuccessScreen(screen) { if (cta.classList.contains('cancel-button')) { const resp = await deleteAttendeeFromEvent(getMetadata('event-id')); - if (!resp.ok) return; + cta.classList.remove('loading'); + + if (!resp.ok) { + buildErrorMsg(screen, resp.status); + return; + } const { data } = resp; + const espStatus = data?.espProvider?.status; - cta.classList.remove('loading'); - if (data?.espProvider?.status !== 204) { - buildErrorMsg(screen); + if ((espStatus && espStatus !== 204)) { + buildErrorMsg(screen, espStatus); return; }