diff --git a/client/src/components/Filters/Services/ScheduleForm/TimeSelect.js b/client/src/components/Filters/Services/ScheduleForm/TimeSelect.js index 60c59edb76f..35998437f69 100644 --- a/client/src/components/Filters/Services/ScheduleForm/TimeSelect.js +++ b/client/src/components/Filters/Services/ScheduleForm/TimeSelect.js @@ -1,13 +1,7 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { getTimeFromMs } from './helpers'; - -const convertHoursToMs = (value) => value * 60 * 60 * 1000; -const convertMinutesToMs = (value) => value * 60 * 1000; - -const convertOnlyHoursToMs = (value) => Math.floor(value / (60 * 60 * 1000)) * 60 * 60 * 1000; -const convertOnlyMinutesToMs = (value) => value % (60 * 60 * 1000); +import { getTimeFromMs, convertTimeToMs } from './helpers'; export const TimeSelect = ({ value, @@ -16,21 +10,19 @@ export const TimeSelect = ({ const { hours: initialHours, minutes: initialMinutes } = getTimeFromMs(value); const [hours, setHours] = useState(initialHours); - const [minute, setMinutes] = useState(initialMinutes); + const [minutes, setMinutes] = useState(initialMinutes); const hourOptions = Array.from({ length: 24 }, (_, i) => i.toString().padStart(2, '0')); const minuteOptions = Array.from({ length: 60 }, (_, i) => i.toString().padStart(2, '0')); const onHourChange = (event) => { setHours(event.target.value); - const newHour = parseInt(event.target.value, 10); - onChange(convertHoursToMs(newHour) + convertOnlyMinutesToMs(value)); + onChange(convertTimeToMs(event.target.value, minutes)); }; const onMinuteChange = (event) => { setMinutes(event.target.value); - const newMinute = parseInt(event.target.value, 10); - onChange(convertOnlyHoursToMs(value) + convertMinutesToMs(newMinute)); + onChange(convertTimeToMs(hours, event.target.value)); }; return ( @@ -48,7 +40,7 @@ export const TimeSelect = ({  :