import { Box, Text } from "@chakra-ui/react"; import { add, getYear, getMonth, sub, getDate,format } from "date-fns"; import router from "next/router"; import React, { Fragment } from "react"; import AddSticker from "./modals/AddSticker"; const Day = ( isOverflow: boolean, date: Date, overflowDirection: "next" | "prev" | null, selectedDate: Date ) => { return ( {isOverflow && ( { if (overflowDirection === "next") { console.log(overflowDirection); const newMonth = add(selectedDate, { months: 1 }); const year = getYear(newMonth); const month = getMonth(newMonth) + 1; router.push(`/calendar/${year}/${month}`); } else if (overflowDirection === "prev") { const newMonth = sub(selectedDate, { months: 1 }); const year = getYear(newMonth); const month = getMonth(newMonth) + 1; router.push(`/calendar/${year}/${month}`); } } })} > {!isOverflow && } {`Day ${getDate(date)}`} )} ); }; export default Day;