import { DatePickerInput } from "@mantine/dates"; import { type FC, useState } from "react"; import { useTranslation } from "react-i18next"; type BankPeriodPickerProps = { period: { from: string; to: string }; onChange: (value: [string | null, string | null]) => void; }; const BankPeriodPicker: FC = (props) => { const { period, onChange } = props; const { t } = useTranslation(); const scope = `${period.from}-${period.to}`; const [draft, setDraft] = useState<{ scope: string; value: [string | null, string | null]; }>(); const value: [string | null, string | null] = draft?.scope === scope ? draft.value : [period.from, period.to]; return ( { setDraft({ scope, value: next }); onChange(next); }} popoverProps={{ returnFocus: true, middlewares: { shift: { crossAxis: true } }, }} /> ); }; export { BankPeriodPicker };