Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
'use client'
|
||||
|
||||
import { createContext, useContext } from 'react'
|
||||
import { EMPTY_EVENT, type PublicEvent } from '@/lib/event-types'
|
||||
|
||||
interface EventContextValue {
|
||||
event: PublicEvent
|
||||
registrationEnabled: boolean
|
||||
}
|
||||
|
||||
const EventContext = createContext<EventContextValue>({ event: EMPTY_EVENT, registrationEnabled: false })
|
||||
|
||||
export function EventProvider({
|
||||
event,
|
||||
registrationEnabled,
|
||||
children,
|
||||
}: EventContextValue & { children: React.ReactNode }) {
|
||||
return <EventContext.Provider value={{ event, registrationEnabled }}>{children}</EventContext.Provider>
|
||||
}
|
||||
|
||||
// Client components read the current edition and its races from here. The root layout
|
||||
// fetches them once per page render.
|
||||
export function useEvent() {
|
||||
return useContext(EventContext)
|
||||
}
|
||||
Reference in New Issue
Block a user