

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

function AddContactModal() {


  const [t] = useTranslation()
  const {mutate , status} = useAddContact()
  const handelSubmit = (values:any )=>{
    console.log(values);
    
    const dataToSend = getDataToSend({...values,direction:values.direction == true ? 1:0,is_have_button:values?.direction == true ? 1:0})

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

    <FormContact />
  </LayoutModal>
  )
}

export default AddContactModal

