Skip to content

Commit

Permalink
Refactored code to eliminate creation of new variable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
WishingWell13 committed Apr 12, 2024
1 parent bc7bfcd commit 4eda486
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@ 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,
start,
end,
description,
orderLimit,
linkedEventUuid: newLinkedID,
linkedEventUuid: linkedEventUuid || null,
});
showToast('Pickup Event created successfully!', '', [
{
Expand Down Expand Up @@ -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,

Expand Down

0 comments on commit 4eda486

Please sign in to comment.