Skip to content

Commit

Permalink
remove form library from changeDueDateDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnC-80 committed Apr 2, 2024
1 parent e278124 commit 81779b6
Showing 1 changed file with 30 additions and 37 deletions.
67 changes: 30 additions & 37 deletions lib/ChangeDueDateDialog/DueDatePickerForm.js
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);

0 comments on commit 81779b6

Please sign in to comment.