import dayjs from 'dayjs' import { isNaN, noop } from 'lodash' import { Clock } from 'lucide-react' import { ChangeEvent, useEffect, useState } from 'react' import { Tooltip, TooltipContent, TooltipTrigger } from 'ui' import type { Time } from './PITR.types' import { formatNumberToTwoDigits, formatTimeToTimeString } from './PITR.utils' // [Joshen] This is trying to do the same thing as TimeSplitInput.tsx // so can we please look to try to combine these 2 components together if possible // The problem with TimeSplitInput is that it's tightly coupled to the date + its // tightly coupled to the context of a range. Ideally it should be more modular // which is what this component is trying to achieve // [Joshen] Potential extension, give option to toggle 24 hours or AM/PM interface TimeInputProps { defaultTime?: Time minimumTime?: Time maximumTime?: Time onChange?: (time: Time) => void } const TimeInput = ({ defaultTime, minimumTime, maximumTime, onChange = noop }: TimeInputProps) => { const [isFocused, setIsFocused] = useState(false) const [error, setError] = useState() const [time, setTime] = useState