import { createContext, type ReactNode, useContext } from "react";
import { useBulkImport } from "../hooks/use-bulk-import.js";

type BulkImportContextValue = ReturnType<typeof useBulkImport>;

const BulkImportContext = createContext<BulkImportContextValue | null>(null);

export function BulkImportProvider({ children }: { children: ReactNode }) {
	const value = useBulkImport();
	return (
		<BulkImportContext.Provider value={value}>
			{children}
		</BulkImportContext.Provider>
	);
}

export function useBulkImportContext(): BulkImportContextValue {
	const ctx = useContext(BulkImportContext);
	if (!ctx) throw new Error("useBulkImportContext requires BulkImportProvider");
	return ctx;
}
