diff --git a/src/gmp/models/event.js b/src/gmp/models/event.js index 592d85f64a..80f97ac658 100644 --- a/src/gmp/models/event.js +++ b/src/gmp/models/event.js @@ -254,14 +254,13 @@ class Event { startDate, summary, weekdays, - isUseUTC = true, }, timezone, ) { const event = new ical.Event(); event.uid = uuid(); - event.startDate = ical.Time.fromJSDate(startDate.toDate(), isUseUTC); + event.startDate = ical.Time.fromJSDate(startDate.toDate(), true); if (isDefined(duration)) { const eventDuration = new ical.Duration(); diff --git a/src/web/components/form/DatePicker.jsx b/src/web/components/form/DatePicker.jsx index c30c892ccf..fa4e7e3837 100644 --- a/src/web/components/form/DatePicker.jsx +++ b/src/web/components/form/DatePicker.jsx @@ -17,7 +17,7 @@ */ import React, {useCallback} from 'react'; -import {DateTimePicker} from '@greenbone/opensight-ui-components'; +import {DatePickerOnly} from '@greenbone/opensight-ui-components'; import {isDefined} from 'gmp/utils/identity'; @@ -31,7 +31,6 @@ const DatePickerComponent = ({ disabled, minDate = date(), name, - width = '100%', value = date(), onChange, label = '', @@ -47,7 +46,7 @@ const DatePickerComponent = ({ ); return ( - ); @@ -66,9 +63,8 @@ const DatePickerComponent = ({ DatePickerComponent.propTypes = { disabled: PropTypes.bool, minDate: PropTypes.oneOfType([PropTypes.date, PropTypes.oneOf([false])]), - name: PropTypes.arrayOf(PropTypes.string), + name: PropTypes.string, value: PropTypes.date.isRequired, - width: PropTypes.string, onChange: PropTypes.func, label: PropTypes.string, }; diff --git a/src/web/pages/performance/startendtimeselection.jsx b/src/web/pages/performance/startendtimeselection.jsx index 1ed8fa4aa6..618cf91490 100644 --- a/src/web/pages/performance/startendtimeselection.jsx +++ b/src/web/pages/performance/startendtimeselection.jsx @@ -24,6 +24,7 @@ import PropTypes from 'web/utils/proptypes'; import Button from 'web/components/form/button'; import DatePicker from 'web/components/form/DatePicker'; import FormGroup from 'web/components/form/formgroup'; +import {TimePicker} from '@greenbone/opensight-ui-components'; import Column from 'web/components/layout/column'; import Row from 'web/components/layout/row'; @@ -37,17 +38,30 @@ const StartTimeSelection = props => { } = props; const [startDate, setStartDate] = useState(initialStartDate); const [endDate, setEndDate] = useState(initialEndDate); + const [startTime, setStartTime] = useState( + `${startDate.hours().toString().padStart(2, '0')}:${startDate.minutes().toString().padStart(2, '0')}`, + ); + + const [endTime, setEndTime] = useState( + `${endDate.hours().toString().padStart(2, '0')}:${endDate.minutes().toString().padStart(2, '0')}`, + ); useEffect(() => { setStartDate(initialStartDate); setEndDate(initialEndDate); }, [initialStartDate, initialEndDate]); - const handleValueChange = (value, name) => { - if (name === 'startDate') { - setStartDate(value); - } else if (name === 'endDate') { - setEndDate(value); + const handleTimeChange = (selectedTime, type) => { + const [hour, minute] = selectedTime.split(':').map(Number); + + if (type === 'startTime') { + const newStartDate = startDate.clone().hours(hour).minutes(minute); + setStartDate(newStartDate); + setStartTime(selectedTime); + } else if (type === 'endTime') { + const newEndDate = endDate.clone().hours(hour).minutes(minute); + setEndDate(newEndDate); + setEndTime(selectedTime); } }; @@ -67,9 +81,15 @@ const StartTimeSelection = props => { + handleTimeChange(newStartTime, 'startTime')} /> @@ -77,14 +97,26 @@ const StartTimeSelection = props => { + handleTimeChange(newEndTime, 'endTime')} /> - diff --git a/src/web/pages/schedules/dialog.jsx b/src/web/pages/schedules/dialog.jsx index d1430f9174..8262cc35a2 100644 --- a/src/web/pages/schedules/dialog.jsx +++ b/src/web/pages/schedules/dialog.jsx @@ -32,6 +32,7 @@ import Spinner from 'web/components/form/spinner'; import FormGroup from 'web/components/form/formgroup'; import TextField from 'web/components/form/textfield'; import DatePicker from 'web/components/form/DatePicker'; +import {TimePicker} from '@greenbone/opensight-ui-components'; import TimeZoneSelect from 'web/components/form/timezoneselect'; import CheckBox from 'web/components/form/checkbox'; @@ -82,14 +83,26 @@ const ScheduleDialog = ({ onSave, }) => { const [_] = useTranslation(); - const [timezone, setTimezone] = useState(initialTimezone); + + const [startDate, setStartDate] = useState(initialStartDate); + + const [startTime, setStartTime] = useState( + `${startDate.hours().toString().padStart(2, '0')}:${startDate.minutes().toString().padStart(2, '0')}`, + ); + + const [endOpen, setEndOpen] = useState(!isDefined(duration)); const [endDate, setEndDate] = useState( isDefined(duration) ? initialStartDate.clone().add(duration) : initialStartDate.clone().add(1, 'hour'), ); - const [startDate, setStartDate] = useState(initialStartDate); - const [endOpen, setEndOpen] = useState(!isDefined(duration)); + + const [endTime, setEndTime] = useState( + `${endDate.hours().toString().padStart(2, '0')}:${endDate.minutes().toString().padStart(2, '0')}`, + ); + + const [timezone, setTimezone] = useState(initialTimezone); + const [freq, setFreq] = useState( isDefined(initialFrequency) ? initialFrequency : ReccurenceFrequency.WEEKLY, ); @@ -214,6 +227,20 @@ const ScheduleDialog = ({ setTimezone(value); }; + const handleTimeChange = (selectedTime, type) => { + const [hour, minute] = selectedTime.split(':').map(Number); + + if (type === 'startTime') { + const newStartDate = startDate.clone().hours(hour).minutes(minute); + setStartDate(newStartDate); + setStartTime(selectedTime); + } else if (type === 'endTime') { + const newEndDate = endDate.clone().hours(hour).minutes(minute); + setEndDate(newEndDate); + setEndTime(selectedTime); + } + }; + const handleSave = ({ comment, endDate, @@ -307,7 +334,6 @@ const ScheduleDialog = ({ // when name is just numbers. summary: `${name}`, startDate, - isUseUTC: false, }, timezone, ); @@ -367,6 +393,21 @@ const ScheduleDialog = ({ onChange={onValueChange} /> + + + handleTimeChange(newStartTime, 'startTime') + } + /> - - -