-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove form library from changeDueDateDialog
- Loading branch information
Showing
1 changed file
with
30 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Row> | ||
<Col xs={12} sm={6} md={3}> | ||
<Datepicker {...dateProps} name="date" onChange={handleChange} value={dateTime.date} /> | ||
</Col> | ||
<Col xs={12} sm={6} md={3}> | ||
<Timepicker {...timeProps} name="time" onChange={handleChange} value={dateTime.time} timeZone="UTC" /> | ||
</Col> | ||
</Row> | ||
); | ||
}; | ||
|
||
render() { | ||
const { dateProps, timeProps } = this.props; | ||
DueDatePickerForm.propTypes = { | ||
dateProps: PropTypes.object, | ||
timeProps: PropTypes.object, | ||
initialValues: PropTypes.object, | ||
onChange: PropTypes.func, | ||
}; | ||
|
||
return ( | ||
<Row> | ||
<Col xs={12} sm={6} md={3}> | ||
<Field | ||
name="date" | ||
component={Datepicker} | ||
timeZone="UTC" | ||
{...dateProps} | ||
/> | ||
</Col> | ||
<Col xs={12} sm={6} md={3}> | ||
<Field | ||
name="time" | ||
component={Timepicker} | ||
timeZone="UTC" | ||
{...timeProps} | ||
/> | ||
</Col> | ||
</Row> | ||
); | ||
} | ||
} | ||
export default DueDatePickerForm; | ||
|
||
export default stripesForm({ | ||
form: 'dueDatePickerForm', | ||
navigationCheck: false, | ||
})(DueDatePickerForm); |