29 lines
549 B
TypeScript
29 lines
549 B
TypeScript
"use client"
|
|
|
|
import { createContext, useContext } from "react"
|
|
|
|
type CustomerContextValue = {
|
|
id: string
|
|
label: string
|
|
}
|
|
|
|
const CustomerContext = createContext<CustomerContextValue | null>(null)
|
|
|
|
export function CustomerProvider({
|
|
customer,
|
|
children,
|
|
}: {
|
|
customer: CustomerContextValue
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<CustomerContext.Provider value={customer}>
|
|
{children}
|
|
</CustomerContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useCustomer() {
|
|
return useContext(CustomerContext)
|
|
}
|