opportunity-hack / evs

Equestrian Volunteer Scheduler
https://www.ohack.dev/nonprofit/89076bcc077811edbfdeb29c4ac23549
MIT License
1 stars 2 forks source link

Remove horse from events during cooldown period #43

Closed parkerdavis1 closed 1 year ago

parkerdavis1 commented 1 year ago

Continuing on from PR https://github.com/opportunity-hack/evs/pull/40

Removes horse from events during cooldown period.

The events are displayed as list of links. Screen Shot 2023-08-06 at 14 14 11

parkerdavis1 commented 1 year ago

Screenshot 2023-08-08 at 10 49 31 AM I didn't change anything here but now there's a typescript error on status. I'm having trouble finding the fortitude to deal with TS.

benhsm commented 1 year ago

You just need to add an as const assertion to the json return value on line 137 so it can treat the status string as an instance of the enum, and an empty conflictEvents array to return cases that don't have conflictEvents so the data returned from the action has a consistent shape

benhsm commented 1 year ago
diff --git a/app/routes/admin+/_horses+/horses.edit.$horseId.tsx b/app/routes/admin+/_horses+/horses.edit.$horseId.tsx
index 057bedf..510b4a8 100644
--- a/app/routes/admin+/_horses+/horses.edit.$horseId.tsx
+++ b/app/routes/admin+/_horses+/horses.edit.$horseId.tsx
@@ -58,13 +58,14 @@ export async function action({ request, params }: DataFunctionArgs) {
    })

    if (submission.intent !== 'submit') {
-       return json({ status: 'idle', submission } as const)
+       return json({ status: 'idle', submission, conflictEvents: [] } as const)
    }
    if (!submission.value) {
        return json(
            {
                status: 'error',
                submission,
+               conflictEvents: [],
            } as const,
            { status: 400 },
        )
@@ -134,7 +135,7 @@ export async function action({ request, params }: DataFunctionArgs) {
                status: 'idle',
                submission,
                conflictEvents,
-           })
+           } as const)
        }
    }

Are things ready to merge otherwise?