garage-erp/apps/dashboard/modules/credit-notes/credit-note-context.tsx

29 lines
573 B
TypeScript

"use client"
import { createContext, useContext } from "react"
type CreditNoteContextValue = {
id: string
label: string
}
const CreditNoteContext = createContext<CreditNoteContextValue | null>(null)
export function CreditNoteProvider({
creditNote,
children,
}: {
creditNote: CreditNoteContextValue
children: React.ReactNode
}) {
return (
<CreditNoteContext.Provider value={creditNote}>
{children}
</CreditNoteContext.Provider>
)
}
export function useCreditNote() {
return useContext(CreditNoteContext)
}