"use client";

import { createContext, useContext, type ReactNode } from "react";
import type { WebsiteConfig } from "@/types";

interface StorefrontConfigContextValue {
  website: Partial<WebsiteConfig>;
}

const StorefrontConfigContext = createContext<StorefrontConfigContextValue>({
  website: {},
});

export function StorefrontConfigProvider({
  website,
  children,
}: {
  website: Partial<WebsiteConfig>;
  children: ReactNode;
}) {
  return (
    <StorefrontConfigContext.Provider value={{ website }}>
      {children}
    </StorefrontConfigContext.Provider>
  );
}

export function useStorefrontConfig(): StorefrontConfigContextValue {
  return useContext(StorefrontConfigContext);
}
