"use client";

import { createContext, useContext } from "react";
import type { CompanyInfo } from "@/types/company";

const CompanyContext = createContext<CompanyInfo | null>(null);

export function useCompany() {
  const ctx = useContext(CompanyContext);
  if (!ctx) throw new Error("useCompany must be used inside CompanyProvider");
  return ctx;
}

export function CompanyProvider({
  company,
  children,
}: {
  company: CompanyInfo;
  children: React.ReactNode;
}) {
  return (
    <CompanyContext.Provider value={company}>
      {children}
    </CompanyContext.Provider>
  );
}
