29 lines
549 B
TypeScript
29 lines
549 B
TypeScript
"use client"
|
|
|
|
import { createContext, useContext } from "react"
|
|
|
|
type EstimateContextValue = {
|
|
id: string
|
|
label: string
|
|
}
|
|
|
|
const EstimateContext = createContext<EstimateContextValue | null>(null)
|
|
|
|
export function EstimateProvider({
|
|
estimate,
|
|
children,
|
|
}: {
|
|
estimate: EstimateContextValue
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<EstimateContext.Provider value={estimate}>
|
|
{children}
|
|
</EstimateContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useEstimate() {
|
|
return useContext(EstimateContext)
|
|
}
|