29 lines
585 B
TypeScript
29 lines
585 B
TypeScript
"use client"
|
|
|
|
import { createContext, useContext } from "react"
|
|
|
|
type AppointmentContextValue = {
|
|
id: string
|
|
label: string
|
|
}
|
|
|
|
const AppointmentContext = createContext<AppointmentContextValue | null>(null)
|
|
|
|
export function AppointmentProvider({
|
|
appointment,
|
|
children,
|
|
}: {
|
|
appointment: AppointmentContextValue
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<AppointmentContext.Provider value={appointment}>
|
|
{children}
|
|
</AppointmentContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useAppointment() {
|
|
return useContext(AppointmentContext)
|
|
}
|