/* eslint-disable react/destructuring-assignment */
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { ReactNode } from 'react';
import type React from 'react';
import { createContext, useState } from 'react';

export type CashFlowSummaryModel = {
	whatIsChecked: number;
	isTrueHandler: () => void;
};

export const CashFlowProfitabilityContext: React.Context<CashFlowSummaryModel> =
	createContext<CashFlowSummaryModel>({
		whatIsChecked: 0,
		isTrueHandler: () => {}
	});

const CashFlowProfitabilityProvider: React.FC<{ children: ReactNode }> = (props: {
	children: ReactNode;
}) => {
	const [whatIsChecked, setWhatIsChecked] = useState<number>(0);

	function isTrueHandler(): void {
		console.log('is true from cash flow profitability');
	}
	// eslint-disable-next-line react/jsx-no-constructed-context-values
	const contextValue = {
		whatIsChecked,
		isTrueHandler
	};
	return (
		<CashFlowProfitabilityContext.Provider value={contextValue}>
			{props.children}
		</CashFlowProfitabilityContext.Provider>
	);
};

export default CashFlowProfitabilityProvider;
