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