"use client"; import { FC, useState, useEffect } from "react"; import { Box, Grid, TextField, Select, MenuItem } from "@mui/material"; import { DatePicker } from "@mui/x-date-pickers-pro"; import { useTranslate } from "react-polyglot"; import { useAppContext } from "./AppProvider"; interface QueryDateRangeSelectorProps {} export const QueryDateRangeSelector: FC = () => { const t = useTranslate(); const [relativeDate, setRelativeDate] = useState(""); const [startDate, setStartDate] = useState(null); const [endDate, setEndDate] = useState(null); const { updateQuery, query } = useAppContext(); useEffect(() => { setStartDate(query.startDate.values[0] ?? null); setEndDate(query.endDate.values[0] ?? null); setRelativeDate(query.relativeDate.values[0] ?? ""); }, [query, setStartDate, setEndDate, setRelativeDate]); return ( – or – { setStartDate(date); updateQuery({ startDate: { values: [date] }, }); }} // @ts-ignore renderInput={(params) => ( )} /> { setEndDate(date); updateQuery({ endDate: { values: [date] }, }); }} // @ts-ignore renderInput={(params) => ( )} /> ); };