From aa16a98157ba2403fca06189b0e87b04024a334c Mon Sep 17 00:00:00 2001 From: Artur Pryka Date: Tue, 14 Jul 2020 10:28:38 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20handle=20datetime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/js/app/queryCreator/components/Filters/Filters.tsx | 6 +++--- .../components/Filters/utils/convertDateToString.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/js/app/queryCreator/components/Filters/Filters.tsx b/lib/js/app/queryCreator/components/Filters/Filters.tsx index 285381f4c..ca410a07c 100644 --- a/lib/js/app/queryCreator/components/Filters/Filters.tsx +++ b/lib/js/app/queryCreator/components/Filters/Filters.tsx @@ -92,9 +92,9 @@ const Filters: FC = ({ collection, filters, onChange }) => { variant="solid" placeholder={'Select property type'} options={dataTypes} - onChange={({ type }: { type: PropertyType }) => { - filtersDispatcher(updateFilter(idx, { propertyType: type })); - setDefaults(idx, type, item?.propertyValue ); + onChange={(type) => { + filtersDispatcher(updateFilter(idx, { propertyType: type.value })); + setDefaults(idx, type.value, item?.propertyValue ); if (item?.operator) { const operatorOptions = getOperatorOptions(type); diff --git a/lib/js/app/queryCreator/components/Filters/utils/convertDateToString.ts b/lib/js/app/queryCreator/components/Filters/utils/convertDateToString.ts index 3ea4cf1f0..b51dad630 100644 --- a/lib/js/app/queryCreator/components/Filters/utils/convertDateToString.ts +++ b/lib/js/app/queryCreator/components/Filters/utils/convertDateToString.ts @@ -4,7 +4,7 @@ const DATE_FORMAT = 'YYYY-MM-DD'; const TIME_FORMAT = 'HH:mm'; export const convertDateToString = (valueSelected) => { - const value = valueSelected || moment(moment().format(DATE_FORMAT)); + const value = moment(valueSelected).isValid() ? valueSelected : moment(moment().format(DATE_FORMAT)); const valueConverted = `${moment(value).format(DATE_FORMAT)}T${moment(value).format( TIME_FORMAT )}:00.000Z`;