From 2d2b4f239c4815a2f919b4a32771478dc4e62879 Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Thu, 8 Aug 2024 03:19:01 -0700 Subject: [PATCH] fix: propertyType date edit should not convert to local timezone (#1694)(@AshotN) --- .../components/property-type/datetime/edit.tsx | 12 ++++++++++-- 1 file changed, 10 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..b42ef2a00 100644 --- a/src/frontend/components/property-type/datetime/edit.tsx +++ b/src/frontend/components/property-type/datetime/edit.tsx @@ -6,10 +6,16 @@ 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: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 - 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 +25,9 @@ const Edit: React.FC = (props) => { onChange(property.path, date)} + onChange={(date) => { + onChange(property.path, property.type === 'date' ? date?.substring(0, 10) ?? date : date) + }} propertyType={property.type} {...property.props} />