"use client";

import type { BillingConfig } from "@/lib/api/billing";
import { createContext, type PropsWithChildren, use } from "react";

type BillingContextValues = {
  config: BillingConfig;
};

const BillingContext = createContext<BillingContextValues>(null as never);

export function BillingContextProvider({
  value,
  children,
}: PropsWithChildren<{ value: BillingContextValues }>) {
  return <BillingContext value={value}>{children}</BillingContext>;
}

export function useBillingConfig() {
  return use(BillingContext).config;
}
