"use client"

import { createContext, useContext } from "react"

export type EstimateContextValue = {
    id: string
    label: string
    data?: Record<string, any>
}

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