Files
lukenyaMarathon_frontend/components/event-provider.tsx
T
KabundiNjuki ff743a1397 Initial commit
2026-10-05 16:40:36 +03:00

26 lines
754 B
TypeScript

'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)
}