37 lines
985 B
TypeScript
37 lines
985 B
TypeScript
"use client"
|
|
|
|
import { createContext, useContext } from "react"
|
|
|
|
export type EstimateContextValue = {
|
|
id?: number | string
|
|
title?: string | null
|
|
estimate_number?: string | null
|
|
discount?: string | null
|
|
sub_total?: number | string | null
|
|
total?: number | string | null
|
|
estimate_parts?: { quantity?: string | number; rate?: string | number }[]
|
|
estimate_services?: { quantity?: string | number; rate?: string | number }[]
|
|
estimate_expense_items?: { quantity?: string | number; rate?: string | number }[]
|
|
[key: string]: unknown
|
|
}
|
|
|
|
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)
|
|
}
|