Commit e98aad46 authored by Maksym Tishchenko's avatar Maksym Tishchenko
Browse files

DateFilter fix format parsing

parent 332c9526
...@@ -38,7 +38,7 @@ interface IDateFilter extends FieldProps<any, any> { ...@@ -38,7 +38,7 @@ interface IDateFilter extends FieldProps<any, any> {
endAdornment?: any; endAdornment?: any;
} }
const validateDateFilter = (val) => !val || DateTime.fromFormat(val, 'yyyy-MM-dd').isValid ? undefined : 'Must be a valid date'; const validateDateFilter = (val) => !val || DateTime.fromISO(val).isValid ? undefined : 'Must be a valid date';
const DateFilter = ({ name, label, endAdornment, ...other }: IDateFilter) => { const DateFilter = ({ name, label, endAdornment, ...other }: IDateFilter) => {
...@@ -53,7 +53,7 @@ const DateFilter = ({ name, label, endAdornment, ...other }: IDateFilter) => { ...@@ -53,7 +53,7 @@ const DateFilter = ({ name, label, endAdornment, ...other }: IDateFilter) => {
const valueLe = getFieldState(`${name}.le`).value; const valueLe = getFieldState(`${name}.le`).value;
// console.log(`DateFilter, valueGe: ${valueGe}, valueLe: ${valueLe}`) // console.log(`DateFilter, valueGe: ${valueGe}, valueLe: ${valueLe}`)
if (valueGe && valueLe && DateTime.fromFormat(valueGe, 'yyyy-MM-dd') > (DateTime.fromFormat(valueLe, 'yyyy-MM-dd'))) { if (valueGe && valueLe && DateTime.fromISO(valueGe) > (DateTime.fromISO(valueLe))) {
// console.log('DateFilter, swapping') // console.log('DateFilter, swapping')
change(`${name}.le`, valueGe); change(`${name}.le`, valueGe);
change(`${name}.ge`, valueLe); change(`${name}.ge`, valueLe);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment