Skip to content

Commit

Permalink
Only handle dates internally
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasLooschen committed Sep 30, 2022
1 parent 834cb4b commit c8ef990
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/components/Inputs/DateTimePicker/DateTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
*/
import { TextField } from '@mui/material';
import { DateTimePicker as MUIDateTimePicker } from '@mui/x-date-pickers';
import { parseISO } from 'date-fns';
import { useController, useFormContext } from 'react-hook-form';
import { getHighlightBackgroundColor, shouldHighlightBackground, shouldShowRequiredLabel, } from '../util';
export function DateTimePicker(_a) {
Expand Down Expand Up @@ -60,6 +61,6 @@ export function DateTimePicker(_a) {
sx: function (theme) { return ({
backgroundColor: getHighlightBackgroundColor(theme, highlightBackground),
}); },
}, inputRef: ref, label: label, value: value === '' ? null : value, onChange: handleChange }, rest)));
}, inputRef: ref, label: label, value: value === '' ? null : parseISO(value), onChange: handleChange }, rest)));
}
export default DateTimePicker;
3 changes: 2 additions & 1 deletion src/components/Inputs/DateTimePicker/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
import { TextField } from '@mui/material';
import { DateTimePicker as MUIDateTimePicker } from '@mui/x-date-pickers';
import { parseISO } from 'date-fns';
import { useController, useFormContext } from 'react-hook-form';

import {
Expand Down Expand Up @@ -86,7 +87,7 @@ export function DateTimePicker({
}}
inputRef={ref}
label={label}
value={value === '' ? null : value}
value={value === '' ? null : parseISO(value)}
onChange={handleChange}
{...rest}
/>
Expand Down

0 comments on commit c8ef990

Please sign in to comment.