Skip to content

Commit

Permalink
Merge pull request #1166 from hackclub/malted/tavern-rsvp-rewrite
Browse files Browse the repository at this point in the history
Rewrite tavern RSVP form
  • Loading branch information
malted authored Feb 3, 2025
2 parents 2cd12c7 + 5188753 commit 6e9e734
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/app/harbor/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default function Harbor({
{
name: <>Tavern 🍻</>,
path: 'tavern',
component: <RateLimit name="The tavern" />,
component: <Tavern />, //<RateLimit name="The tavern" />,
// component: process.env.NEXT_PUBLIC_LOW_RATE_LIMIT ? (
// <RateLimit name="The tavern" />
// ) : (
Expand Down
23 changes: 22 additions & 1 deletion src/app/harbor/tavern/tavern-utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
'use server'

import { getSession } from '@/app/utils/auth'
import {
setTavernRsvpStatus,
submitMyTavernLocation,
submitShirtSize,
} from '@/app/utils/tavern'
import Airtable from 'airtable'

Airtable.configure({
apiKey: process.env.AIRTABLE_API_KEY,
endpointUrl: process.env.AIRTABLE_ENDPOINT_URL,
})

type RsvpStatus = 'none' | 'organizer' | 'participant'
export type RsvpStatus = 'none' | 'organizer' | 'participant'
export type TavernPersonItem = {
status: RsvpStatus
coordinates: string
Expand Down Expand Up @@ -102,3 +107,19 @@ export const getTavernEvents = async () => {
lastEventsFetch = Date.now()
return items
}

export async function rspvForTavern(formData: FormData) {
let res = { success: true, error: null }

await Promise.all([
setTavernRsvpStatus(formData.get('rsvp') as RsvpStatus),
submitMyTavernLocation(formData.get('tavern') as string),
submitShirtSize(formData.get('shirt') as string),
]).catch((error) => {
console.error('Error submitting tavern RSVP', error)
res = { success: false, error: error.toString() }
})

console.log('Successfully saved tavern RSVP')
return JSON.stringify(res)
}
Loading

0 comments on commit 6e9e734

Please sign in to comment.