49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import { DatePicker } from "antd";
|
|
import dayjs from "../../utils/day.js";
|
|
import React, { useRef } from "react";
|
|
|
|
import { connect } from "react-redux";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { selectBodyshop } from "../../redux/user/user.selectors.js";
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
bodyshop: selectBodyshop
|
|
});
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
|
});
|
|
export default connect(mapStateToProps, mapDispatchToProps)(FormDateTimePickerEnhanced);
|
|
|
|
const dateFormat = "MM/DD/YYYY h:mm a";
|
|
|
|
export function FormDateTimePickerEnhanced({
|
|
bodyshop,
|
|
value,
|
|
onBlur,
|
|
onlyFuture,
|
|
onlyToday,
|
|
isDateOnly = true,
|
|
...restProps
|
|
}) {
|
|
const ref = useRef();
|
|
return (
|
|
<div>
|
|
<DatePicker
|
|
ref={ref}
|
|
value={value ? dayjs(value) : null}
|
|
format={dateFormat}
|
|
onBlur={onBlur}
|
|
showToday={false}
|
|
disabledDate={(d) => {
|
|
if (onlyToday) {
|
|
return !dayjs().isSame(d, "day");
|
|
} else if (onlyFuture) {
|
|
return dayjs().subtract(1, "day").isAfter(d);
|
|
}
|
|
}}
|
|
{...restProps}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|