

  import React from 'react'
  import LayoutModal from '../../Layout/Dashboard/LayoutModal'
  import FormProduct from './FormProduct'
  import { useAddProduct } from '../../api/product'
  import { getDataToSend, getInitialValues, getValidationSchema } from './formUtil'
  import { QueryStatusEnum } from '../../config/QueryStatus'
  import { useTranslation } from 'react-i18next'

  function AddProductModal() {


    const [t] = useTranslation()
    const {mutate , status} = useAddProduct()
    const handelSubmit = (values:any )=>{
      console.log(values);
      
      const dataToSend = getDataToSend(values)

      mutate(dataToSend)
      // Submit Value
    }   
    return (
      <LayoutModal
      isAddModal={true}
      getInitialValues={getInitialValues()} 
      handleSubmit={handelSubmit} 
      status={status as QueryStatusEnum}
      headerText={t('Add') +t('product')}
      
      getValidationSchema={getValidationSchema()}>

      <FormProduct />
    </LayoutModal>
    )
  }

  export default AddProductModal

