import { isDevelopment } from '@websolutespa/bom-core';
import { createGenericContext } from '@websolutespa/bom-mixer-hooks';
import React from 'react';

export type IFormTesterOptions = {
  enabled: boolean;
};

const defaultFormTester: IFormTesterOptions = {
  enabled: isDevelopment,
};

const [useFormTester, FormTesterContextProvider] = createGenericContext<IFormTesterOptions>(defaultFormTester);

function FormTesterProvider({ children, options }: { children?: React.ReactNode, options?: Partial<IFormTesterOptions> }) {
  return (
    <FormTesterContextProvider value={{ ...defaultFormTester, ...options }}>
      {children}
    </FormTesterContextProvider>
  );
}

export { FormTesterProvider, useFormTester };

