29 lines
549 B
TypeScript
29 lines
549 B
TypeScript
"use client"
|
|
|
|
import { createContext, useContext } from "react"
|
|
|
|
type EmployeeContextValue = {
|
|
id: string
|
|
label: string
|
|
}
|
|
|
|
const EmployeeContext = createContext<EmployeeContextValue | null>(null)
|
|
|
|
export function EmployeeProvider({
|
|
employee,
|
|
children,
|
|
}: {
|
|
employee: EmployeeContextValue
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<EmployeeContext.Provider value={employee}>
|
|
{children}
|
|
</EmployeeContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useEmployee() {
|
|
return useContext(EmployeeContext)
|
|
}
|