

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

function AddCouponModal() {


  const [t] = useTranslation()
  const {mutate , status} = useAddCoupon()
  const handelSubmit = (values:any )=>{
    values['name'] = {
      "en" : values.name_en,
      "ar" : values.name_ar,
      "de" : values.name_de,
    } 
    console.log(values);
    mutate(values) 

  }
  return (
    <LayoutModal
      
     isAddModal={true}
     getInitialValues={getInitialValues()} 
     handleSubmit={handelSubmit} 
     status={status as QueryStatusEnum}
     headerText={t('Add') +t('Coupon')}
     
     getValidationSchema={getValidationSchema()}>

    <AddForm />
  </LayoutModal>
  )
}

export default AddCouponModal

