Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: propertyType date edit should not convert to local timezone #1694

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/frontend/components/property-type/datetime/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
AshotN marked this conversation as resolved.
Show resolved Hide resolved

const Edit: React.FC<EditPropertyProps> = (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) : ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

record.params defaults to {} afaik so this will be truthy always

const error = record.errors && record.errors[property.path]
const { tm } = useTranslation()

Expand All @@ -19,7 +22,9 @@ const Edit: React.FC<EditPropertyProps> = (props) => {
<DatePicker
value={value}
disabled={property.isDisabled}
onChange={(date) => onChange(property.path, date)}
onChange={(date) => {
onChange(property.path, property.type === 'date' ? date?.substring(0, 10) ?? date : date)
}}
propertyType={property.type}
{...property.props}
/>
Expand Down
Loading