"use client";

import { createContext, useContext } from "react";

const PaidSupportContext = createContext<boolean | undefined>(undefined);

export function PaidSupportProvider({
  eligible,
  children,
}: {
  eligible: boolean;
  children: React.ReactNode;
}) {
  return (
    <PaidSupportContext.Provider value={eligible}>{children}</PaidSupportContext.Provider>
  );
}

/** True when the signed-in user has a paid order or active entitlement (WhatsApp unlock). */
export function usePaidSupport(): boolean {
  return useContext(PaidSupportContext) ?? false;
}
