From f39d1161d55d6ac99de20b1e9e71d9de31be7395 Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Wed, 31 Jul 2024 15:04:50 -0700 Subject: [PATCH 1/3] fix: propertyType date edit should not convert to local timezone --- src/frontend/components/property-type/datetime/edit.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/components/property-type/datetime/edit.tsx b/src/frontend/components/property-type/datetime/edit.tsx index 6249709c7..6d15f48c4 100644 --- a/src/frontend/components/property-type/datetime/edit.tsx +++ b/src/frontend/components/property-type/datetime/edit.tsx @@ -6,10 +6,13 @@ import { recordPropertyIsEqual } from '../record-property-is-equal.js' import { PropertyLabel } from '../utils/property-label/index.js' import allowOverride from '../../../hoc/allow-override.js' import { useTranslation } from '../../../hooks/index.js' +import { PropertyType } from '../../../../backend/index.js' + +const formatDate = (val:any, propertyType: PropertyType) => (propertyType === 'date' ? `${val}T00:00:00` : val) const Edit: React.FC = (props) => { const { property, onChange, record } = props - const value = (record.params && record.params[property.path]) || '' + const value = record.params ? formatDate(record.params[property.path], property.type) : '' const error = record.errors && record.errors[property.path] const { tm } = useTranslation() @@ -19,7 +22,9 @@ const Edit: React.FC = (props) => { onChange(property.path, date)} + onChange={(date) => { + onChange(property.path, date?.substring(0, 10) ?? date) + }} propertyType={property.type} {...property.props} /> From 0d65eea57700d4dac2f00063c4918975177a8ecc Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Wed, 31 Jul 2024 15:16:58 -0700 Subject: [PATCH 2/3] fix: date-time timestamp should not be omitted --- src/frontend/components/property-type/datetime/edit.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/components/property-type/datetime/edit.tsx b/src/frontend/components/property-type/datetime/edit.tsx index 6d15f48c4..4c80919da 100644 --- a/src/frontend/components/property-type/datetime/edit.tsx +++ b/src/frontend/components/property-type/datetime/edit.tsx @@ -23,7 +23,7 @@ const Edit: React.FC = (props) => { value={value} disabled={property.isDisabled} onChange={(date) => { - onChange(property.path, date?.substring(0, 10) ?? date) + onChange(property.path, property.type === 'date' ? date?.substring(0, 10) ?? date : date) }} propertyType={property.type} {...property.props} From 03e68b6f4cb128e11852988a1ddc8a883d1bcbde Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Thu, 1 Aug 2024 12:13:47 -0700 Subject: [PATCH 3/3] fix: handle null better --- src/frontend/components/property-type/datetime/edit.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/components/property-type/datetime/edit.tsx b/src/frontend/components/property-type/datetime/edit.tsx index 4c80919da..b42ef2a00 100644 --- a/src/frontend/components/property-type/datetime/edit.tsx +++ b/src/frontend/components/property-type/datetime/edit.tsx @@ -8,7 +8,10 @@ import allowOverride from '../../../hoc/allow-override.js' import { useTranslation } from '../../../hooks/index.js' import { PropertyType } from '../../../../backend/index.js' -const formatDate = (val:any, propertyType: PropertyType) => (propertyType === 'date' ? `${val}T00:00:00` : val) +const formatDate = (val:string|null, propertyType: PropertyType) => { + if (val) return (propertyType === 'date' ? `${val}T00:00:00` : val) + return '' +} const Edit: React.FC = (props) => { const { property, onChange, record } = props