garage-erp/apps/dashboard/modules/estimates/estimate-context.tsx
Mohammad Khyata 65964605e1 updates
Co-authored-by: Copilot <copilot@github.com>
2026-04-24 12:20:10 +03:00

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