logic was moved to sepate functions

This commit is contained in:
Vladimir Khvan 2023-02-02 16:39:48 +05:00
parent e38aed5433
commit 74e2d13e43

View File

@ -1,18 +1,9 @@
import { CurrentDateItem, DateItem, SecondaryDateItem } from "../styled-components";
import { MonthsContainer } from "../styled-components/MonthsContainer";
import moment from "moment";
import { getCalendarMonths, getMonthElements } from "../utils";
export const MonthsBody = ({selectedDate}) => {
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar', 'Apr'];
console.log(`${selectedDate.year()}-${moment().month('Jan').format('M')}`)
const monthsElements = months.map(month => <DateItem big>{month}</DateItem>);
for(let i = 12; i < 16; i++) {
monthsElements[i] = <SecondaryDateItem big>{months[i]}</SecondaryDateItem>;
}
monthsElements[0] = <CurrentDateItem big>{months[0]}</CurrentDateItem>;
export const MonthsBody = ({ selectedDate, setSelectedDate }) => {
const months = getCalendarMonths(selectedDate);
const monthsElements = getMonthElements(months, setSelectedDate);
return <MonthsContainer>{monthsElements}</MonthsContainer>;
}
};