Rev 14172 | Rev 15238 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useState } from 'react'
import Datetime from 'react-datetime'
import 'react-datetime/css/react-datetime.css'
import { useDispatch } from 'react-redux'
import { addNotification } from '../../../redux/notification/notification.actions'
import SubmitModal from './SubmitModal'
const LastAplicationDayModal = ({
closeModal,
dataLink,
modalData
}) => {
const [year, setYear] = useState(modalData)
const dispatch = useDispatch()
return (
<SubmitModal
submitData={{ last_date_of_application: year }}
closeModal={closeModal}
postLink={dataLink}
title='Último día de aplicación'
>
<Datetime
dateFormat="DD-MM-YYYY"
timeFormat={false}
onChange={(e) => {
if (Date.now() > new Date(e.toDate()).getTime()) {
return dispatch(addNotification({
style: 'danger',
msg: 'La fecha no puede ser igual o anterior a la actual'
}))
}
setYear(new Intl.DateTimeFormat({ year: 'numeric', month: 'numeric', day: 'numeric' }).format(e.toDate()))
}}
initialValue={new Date(new Intl.DateTimeFormat('es-ES', year).format())}
inputProps={{ className: 'form-control' }}
closeOnSelect
/>
</SubmitModal>
)
}
export default LastAplicationDayModal