- Add OnlyToday

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-01-22 14:38:56 -05:00
parent f02aa36b8d
commit e46be6c12b
2 changed files with 18 additions and 5 deletions

View File

@@ -188,7 +188,7 @@ const EulaFormComponent = ({ form, handleChange, onFinish, t }) => (
},
]}
>
<FormDatePicker onChange={handleChange} onlyFuture
<FormDatePicker onChange={handleChange} onlyToday
aria-label={t('eula.labels.date_accepted')} />
</Form.Item>
</Col>

View File

@@ -16,7 +16,16 @@ export default connect(mapStateToProps, mapDispatchToProps)(FormDatePicker);
const dateFormat = "MM/DD/YYYY";
export function FormDatePicker({bodyshop, value, onChange, onBlur, onlyFuture, isDateOnly = true, ...restProps }) {
export function FormDatePicker({
bodyshop,
value,
onChange,
onBlur,
onlyFuture,
onlyToday,
isDateOnly = true,
...restProps
}) {
const ref = useRef();
const handleChange = (newDate) => {
@@ -87,9 +96,13 @@ export function FormDatePicker({bodyshop, value, onChange, onBlur, onlyFuture, i
onBlur={onBlur || handleBlur}
showToday={false}
disabledTime
{...(onlyFuture && {
disabledDate: (d) => dayjs().subtract(1, "day").isAfter(d),
})}
disabledDate={(d) => {
if (onlyToday) {
return !dayjs().isSame(d, 'day');
} else if (onlyFuture) {
return dayjs().subtract(1, "day").isAfter(d);
}
}}
{...restProps}
/>
</div>