@@ -16,8 +16,6 @@ import { type SubmitHandler, useForm } from 'react-hook-form';
16
16
import { yupResolver } from '@hookform/resolvers/yup' ;
17
17
import { FormContainer , SelectElement , TextareaAutosizeElement } from 'react-hook-form-mui' ;
18
18
import { DateTimePickerElement , type DateTimePickerElementProps } from 'react-hook-form-mui/date-pickers' ;
19
- import { TZDate } from '@date-fns/tz' ;
20
- import { endOfMinute , startOfMinute } from 'date-fns' ;
21
19
import { UserAdminSrv } from '../../services' ;
22
20
import { getErrorMessage , handleAnnouncementCreationErrors } from '../../utils/error' ;
23
21
@@ -50,7 +48,7 @@ const formSchema = yup
50
48
type FormSchema = InferType < typeof formSchema > ;
51
49
52
50
const datetimePickerTransform : NonNullable < DateTimePickerElementProps < FormSchema > [ 'transform' ] > = {
53
- input : ( value ) => ( value ? new TZDate ( value ) : null ) ,
51
+ input : ( value ) => ( value ? new Date ( value ) : null ) ,
54
52
output : ( value ) => value ?. toISOString ( ) ?? '' ,
55
53
} ;
56
54
const pickerView = [ 'year' , 'month' , 'day' , 'hours' , 'minutes' ] as const satisfies readonly DateOrTimeView [ ] ;
@@ -76,8 +74,8 @@ export default function AddAnnouncementForm({ onAnnouncementCreated }: Readonly<
76
74
UserAdminSrv . addAnnouncement ( {
77
75
//id: crypto.randomUUID(),
78
76
message : params . message ,
79
- startDate : startOfMinute ( new TZDate ( params . startDate ) ) . toISOString ( ) ,
80
- endDate : endOfMinute ( new TZDate ( params . endDate ) ) . toISOString ( ) ,
77
+ startDate : params . startDate ,
78
+ endDate : params . endDate ,
81
79
severity : params . severity ,
82
80
} )
83
81
. then ( ( ) => onAnnouncementCreated ?.( ) )
@@ -125,7 +123,7 @@ export default function AddAnnouncementForm({ onAnnouncementCreated }: Readonly<
125
123
views = { pickerView }
126
124
timeSteps = { { hours : 1 , minutes : 1 , seconds : 0 } }
127
125
disablePast
128
- minDateTime = { startDateValue ? new TZDate ( startDateValue ) : undefined }
126
+ minDateTime = { startDateValue ? new Date ( startDateValue ) : undefined }
129
127
/>
130
128
</ Grid >
131
129
< Grid item xs = { 2 } >
0 commit comments