import { createContext, PropsWithChildren } from "react";

import { useDialogStore } from "@/contexts/dialog/lib/useDialogStore";

export interface Context {
	assetIdList: string[];
	closeDialog: () => void;
}

export const context = createContext<Context>({
	assetIdList: [],
	closeDialog: () => {},
});

interface Props extends PropsWithChildren {
	assetIdList: string[];
}

export function ReportBuilderContextProvider({ children, assetIdList }: Props) {
	const dialog = useDialogStore();

	return (
		<context.Provider
			value={{
				assetIdList,
				closeDialog: () => dialog.back(),
			}}
		>
			{children}
		</context.Provider>
	);
}
