import { useState } from 'react';
import { extractFormData } from '../utils';

export const useForm = (initialFormData: any, formik: boolean = false) => {
  const [formData, setFormData] = useState<any>(initialFormData);

  return formik ? [formData, (values: any) => setFormData(values)] : [
    formData,
    (e: any) => setFormData(extractFormData(e))
  ];
};
