File tree Expand file tree Collapse file tree
src/frontend/components/property-type/datetime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,10 +6,16 @@ import { recordPropertyIsEqual } from '../record-property-is-equal.js'
66import { PropertyLabel } from '../utils/property-label/index.js'
77import allowOverride from '../../../hoc/allow-override.js'
88import { useTranslation } from '../../../hooks/index.js'
9+ import { PropertyType } from '../../../../backend/index.js'
10+
11+ const formatDate = ( val :string | null , propertyType : PropertyType ) => {
12+ if ( val ) return ( propertyType === 'date' ? `${ val } T00:00:00` : val )
13+ return ''
14+ }
915
1016const Edit : React . FC < EditPropertyProps > = ( props ) => {
1117 const { property, onChange, record } = props
12- const value = ( record . params && record . params [ property . path ] ) || ''
18+ const value = record . params ? formatDate ( record . params [ property . path ] , property . type ) : ''
1319 const error = record . errors && record . errors [ property . path ]
1420 const { tm } = useTranslation ( )
1521
@@ -19,7 +25,9 @@ const Edit: React.FC<EditPropertyProps> = (props) => {
1925 < DatePicker
2026 value = { value }
2127 disabled = { property . isDisabled }
22- onChange = { ( date ) => onChange ( property . path , date ) }
28+ onChange = { ( date ) => {
29+ onChange ( property . path , property . type === 'date' ? date ?. substring ( 0 , 10 ) ?? date : date )
30+ } }
2331 propertyType = { property . type }
2432 { ...property . props }
2533 />
You can’t perform that action at this time.
0 commit comments