import React, {Fragment} from "react"; import JDIcon from "../../../icons/Icons"; import {IUseDayPicker, LANG} from "../../../../hooks/hook"; import moment from "moment"; type IProps = { dayPickerHook: IUseDayPicker; format?: string; } const ArrowDayByDay: React.FC = ({ dayPickerHook, format = `MM${LANG("month")} DD${LANG("date")}`, ...props }) => { const handleDayPickerArrow = (direction: "prev" | "next") => { const directionNum = direction === "prev" ? -1 : 1; dayPickerHook.setDate( moment(dayPickerHook.from || undefined) .add(directionNum, "days") .toDate() ); }; return ( { e.preventDefault(); handleDayPickerArrow("prev"); }} icon="arrowLeft" /> {moment(dayPickerHook.from || new Date()).format(format)} { e.stopPropagation(); handleDayPickerArrow("next"); }} icon="arrowRight" /> ); }; export default ArrowDayByDay;