import React, { useEffect, useState } from 'react';
import { DatePicker } from 'antd';
import { MomentToTime, TimeToMoment2 } from '@/utils/time';
import moment from 'moment';


const TimeComfirm = (props:any) => {

  const { value, onChange } = props
  
  const [val, setVal] = useState(null);
  useEffect(() => {
    if (value != null) {   
      setVal(TimeToMoment2(value))
    }
  },[value])
  const onsubmit = (values: any) => {
    onChange(MomentToTime(values))    
  }
  return (
    <>
      {
        val != null ?
          <><DatePicker showTime defaultValue={val} onOk={onsubmit} /></> :
          <DatePicker showTime onOk={onsubmit} />
      }
      
    </>
  );
};

export default TimeComfirm;
