import { Group, ActionIcon, CloseButton } from "@mantine/core"; import { DatesProvider, DateTimePicker } from "@mantine/dates"; import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react"; import { FC } from "react"; import { useAppSelector } from "../../state/hooks"; interface TimeInputProps { time: number | null; // Timestamp in milliseconds. range: number; // Range in seconds. description: string; onChangeTime: (time: number | null) => void; } const iconStyle = { width: "0.9rem", height: "0.9rem" }; const TimeInput: FC = ({ time, range, description, onChangeTime, }) => { const baseTime = () => (time !== null ? time : Date.now().valueOf()); const useLocalTime = useAppSelector((state) => state.settings.useLocalTime); return ( onChangeTime(value ? value.getTime() : null)} aria-label={description} placeholder={description} onClick={() => { if (time === null) { onChangeTime(baseTime()); } }} leftSection={ onChangeTime(baseTime() - range / 2)} > } styles={{ section: { width: "unset" } }} rightSection={ <> {time && ( event.preventDefault()} tabIndex={-1} onClick={() => { onChangeTime(null); }} size="xs" /> )} onChangeTime(baseTime() + range / 2)} > } /> ); }; export default TimeInput;