diff --git a/lib/ChangeDueDateDialog/DueDatePickerForm.js b/lib/ChangeDueDateDialog/DueDatePickerForm.js index 2e0a9b785..07785f230 100644 --- a/lib/ChangeDueDateDialog/DueDatePickerForm.js +++ b/lib/ChangeDueDateDialog/DueDatePickerForm.js @@ -1,43 +1,36 @@ -import React from 'react'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { Field } from 'redux-form'; - -import stripesForm from '@folio/stripes-form'; import { Col, Datepicker, Row, Timepicker } from '@folio/stripes-components'; -class DueDatePickerForm extends React.Component { - static propTypes = { - dateProps: PropTypes.object, - timeProps: PropTypes.object, - } +const DueDatePickerForm = ({ initialValues, onChange, dateProps, timeProps }) => { + const [dateTime, updateDateTime] = useState({ ...initialValues }); + + React.useEffect(() => onChange(dateTime), [dateTime.date, dateTime.time, onChange]); // eslint-disable-line + + const handleChange = (e, _value, formattedValue) => { + updateDateTime((cur) => { + return { ...cur, [e.target.name]: formattedValue }; + }); + }; + + return ( + + + + + + + + + ); +}; - render() { - const { dateProps, timeProps } = this.props; +DueDatePickerForm.propTypes = { + dateProps: PropTypes.object, + timeProps: PropTypes.object, + initialValues: PropTypes.object, + onChange: PropTypes.func, +}; - return ( - - - - - - - - - ); - } -} +export default DueDatePickerForm; -export default stripesForm({ - form: 'dueDatePickerForm', - navigationCheck: false, -})(DueDatePickerForm);