File tree 1 file changed +10
-2
lines changed
src/frontend/components/property-type/datetime
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,16 @@ import { recordPropertyIsEqual } from '../record-property-is-equal.js'
6
6
import { PropertyLabel } from '../utils/property-label/index.js'
7
7
import allowOverride from '../../../hoc/allow-override.js'
8
8
import { 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
+ }
9
15
10
16
const Edit : React . FC < EditPropertyProps > = ( props ) => {
11
17
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 ) : ''
13
19
const error = record . errors && record . errors [ property . path ]
14
20
const { tm } = useTranslation ( )
15
21
@@ -19,7 +25,9 @@ const Edit: React.FC<EditPropertyProps> = (props) => {
19
25
< DatePicker
20
26
value = { value }
21
27
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
+ } }
23
31
propertyType = { property . type }
24
32
{ ...property . props }
25
33
/>
You can’t perform that action at this time.
0 commit comments