From 4eda4863b1066d43be82bdfedb02afc5a8bfc682 Mon Sep 17 00:00:00 2001 From: Andrew Smithwick Date: Thu, 11 Apr 2024 18:01:14 -0700 Subject: [PATCH] Refactored code to eliminate creation of new variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You have to specify the key name like linkedEventUuid: linkedEventUuid || null the shorthand only works if you pass in a single variable that’s used as the key and value like u did for title --- .../AdminPickupEvent/AdminPickupEventForm.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/admin/event/AdminPickupEvent/AdminPickupEventForm.tsx b/src/components/admin/event/AdminPickupEvent/AdminPickupEventForm.tsx index 5656a26b..d57699d6 100644 --- a/src/components/admin/event/AdminPickupEvent/AdminPickupEventForm.tsx +++ b/src/components/admin/event/AdminPickupEvent/AdminPickupEventForm.tsx @@ -93,8 +93,6 @@ const AdminPickupEventForm = ({ mode, defaultData = {}, token, upcomingEvents }: const end = new Date(isoEnd).toISOString(); const orderLimit = parseInt(`${rawOrderLimit}`, 10); - const newLinkedID = linkedEventUuid === '' ? null : linkedEventUuid; - try { const uuid = await AdminEventManager.createPickupEvent(token, { title, @@ -102,7 +100,7 @@ const AdminPickupEventForm = ({ mode, defaultData = {}, token, upcomingEvents }: end, description, orderLimit, - linkedEventUuid: newLinkedID, + linkedEventUuid: linkedEventUuid || null, }); showToast('Pickup Event created successfully!', '', [ { @@ -130,15 +128,20 @@ const AdminPickupEventForm = ({ mode, defaultData = {}, token, upcomingEvents }: orderLimit: rawOrderLimit, } = formData; - const newLinkedID = linkedEventUuid === '' ? null : linkedEventUuid; - const start = new Date(isoStart).toISOString(); const end = new Date(isoEnd).toISOString(); const orderLimit = parseInt(`${rawOrderLimit}`, 10); try { await AdminEventManager.editPickupEvent({ - pickupEvent: { title, start, end, description, orderLimit, linkedEventUuid: newLinkedID }, + pickupEvent: { + title, + start, + end, + description, + orderLimit, + linkedEventUuid: linkedEventUuid || null, + }, uuid: defaultData.uuid ?? '', token: token,