
import React from 'react'
import LayoutModal from '../../Layout/Dashboard/LayoutModal'
import FormServices from './FormServices'
import { InitialValues, getDataToSend, getInitialValues, getValidationSchema } from './formUtil'
import { usePageState } from '../../lib/state mangment/LayoutPagestate'
import { useUpdateServices } from '../../api/Services'
import { QueryStatusEnum } from '../../config/QueryStatus'

function EditServicesModal() {
  const {objectToEdit} = usePageState()
  const {status , mutate } = useUpdateServices();
  const handleSubmit = (value:InitialValues)=>{

    const dataToSend = getDataToSend({...value})

    mutate(dataToSend)
    
}
  return (
    <LayoutModal 
     isAddModal={false}
     getInitialValues={getInitialValues(objectToEdit)} 
     handleSubmit={handleSubmit}
     headerText='Edit Modal' 
     status={status as QueryStatusEnum}
     getValidationSchema={getValidationSchema(objectToEdit)}>
      <FormServices />
    </LayoutModal>
  )
}

export default EditServicesModal
