From 350f4b7dc92e7295998322f49ff5822ba24f5754 Mon Sep 17 00:00:00 2001 From: Marius Obert Date: Fri, 11 Oct 2024 13:03:14 +0200 Subject: [PATCH 1/2] fix formatting --- src/app/event/[slug]/orders/ordersList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/event/[slug]/orders/ordersList.tsx b/src/app/event/[slug]/orders/ordersList.tsx index d6b0ec0..65d3db4 100644 --- a/src/app/event/[slug]/orders/ordersList.tsx +++ b/src/app/event/[slug]/orders/ordersList.tsx @@ -71,7 +71,7 @@ export default function OrdersList({ value="cancelled" > Cancelled - {event?.cancelledCount && ( + {event?.cancelledCount != undefined && ( {event?.cancelledCount} )} @@ -81,7 +81,7 @@ export default function OrdersList({ value="delivered" > Delivered - {event?.deliveredCount && ( + {event?.deliveredCount != undefined && ( {event?.deliveredCount} )} From 32b039a9ce5cd6ca2914f46df5e2a2920d2bbc91 Mon Sep 17 00:00:00 2001 From: Marius Obert Date: Fri, 11 Oct 2024 13:11:35 +0200 Subject: [PATCH 2/2] make clear script more dynamic --- src/scripts/clearOrdersForEvent.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/scripts/clearOrdersForEvent.ts b/src/scripts/clearOrdersForEvent.ts index 1a1f899..9b5a421 100644 --- a/src/scripts/clearOrdersForEvent.ts +++ b/src/scripts/clearOrdersForEvent.ts @@ -12,13 +12,26 @@ const client = twilio(TWILIO_API_KEY, TWILIO_API_SECRET, { accountSid: TWILIO_ACCOUNT_SID, }); -const eventName = "wwc-2024"; +const eventName = process.argv.pop(); + +if (!eventName || eventName.startsWith("/") || eventName.includes("=")) { + console.error("Please provide an event name as the last argument, e.g. 'pnpm clear-orders wearedevs24'"); + process.exit(1); +} (async () => { - await updateSyncMapItem("Events", eventName, { - cancelledCount: 0, - deliveredCount: 0, - }); + try { + await updateSyncMapItem("Events", eventName, { + cancelledCount: 0, + deliveredCount: 0, + }); + } catch (e: any) { + if (e.code === 20404) { + console.error(`Event ${eventName} not found`); + process.exit(0); + } + console.error(e); + } console.log( `Reset event stats "cancelledCount" and "deliveredCount" for ${eventName}`,