Skip to content

Commit

Permalink
Added function to parse props
Browse files Browse the repository at this point in the history
for complete and cancel functions
  • Loading branch information
WishingWell13 committed Apr 13, 2024
1 parent 266390e commit 7ea90e6
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ interface IProps {
upcomingEvents: PublicEvent[];
}

const parseProps = (isoStart: string, isoEnd: string, rawOrderLimit: string) => {
const start = new Date(isoStart).toISOString();
const end = new Date(isoEnd).toISOString();
const orderLimit = parseInt(`${rawOrderLimit}`, 10);
return { start, end, orderLimit };
};

export const completePickupEvent = async (uuid: UUID, token: string) => {
try {
await AdminEventManager.completePickupEvent({
Expand Down Expand Up @@ -90,9 +97,7 @@ const AdminPickupEventForm = ({ mode, defaultData = {}, token, upcomingEvents }:
} = formData;

try {
const start = new Date(isoStart).toISOString();
const end = new Date(isoEnd).toISOString();
const orderLimit = parseInt(`${rawOrderLimit}`, 10);
const { start, end, orderLimit } = parseProps(isoStart, isoEnd, `${rawOrderLimit}`);

const uuid = await AdminEventManager.createPickupEvent(token, {
title,
Expand Down Expand Up @@ -133,9 +138,7 @@ const AdminPickupEventForm = ({ mode, defaultData = {}, token, upcomingEvents }:
} = formData;

try {
const start = new Date(isoStart).toISOString();
const end = new Date(isoEnd).toISOString();
const orderLimit = parseInt(`${rawOrderLimit}`, 10);
const { start, end, orderLimit } = parseProps(isoStart, isoEnd, `${rawOrderLimit}`);

await AdminEventManager.editPickupEvent({
pickupEvent: {
Expand Down

0 comments on commit 7ea90e6

Please sign in to comment.