import React, { useState, useEffect } from 'react'; import style from './CalendarComponent.module.css'; import ellipse from '../../images/ellipse.png'; import rectangle from '../../images/rectangle__calendar.png'; import calendarIcon from '../../images/calendar_icon.png'; import moment from 'moment'; import 'moment/locale/ru'; import { calendarHelper, currentMonthAndDay } from './calendarHelper'; const CalendarComponent = () => { const [value, setValue] = useState(moment()); const [calendar, setCalendar] = useState([]); useEffect(() => { setCalendar(calendarHelper(value)); }, [value]); function beforeToday(day) { return day.isBefore(new Date(), 'day'); } function isToday(day) { return day.isSame(new Date(), 'day'); } function dayStyles(day) { if (beforeToday(day)) return `${style.before}`; if (isToday(day)) return `${style.today}`; if (day.day() === 6 || day.day() === 0) return `${style.selected}`; return ''; } function prevMonth() { return value.clone().subtract(1, 'month'); } function nextMonth() { return value.clone().subtract(2, 'month'); } const prevMonthFirst = () => { return moment().subtract(1, 'month').format('MMMM'); }; const prevMonthSecond = () => { return moment().subtract(2, 'month').format('MMMM'); }; return (

Мои отчеты

setValue(prevMonth())}>{prevMonthFirst()}
setValue(nextMonth())}>{prevMonthSecond()}

Пн

Вт

Ср

Чт

Пт

Сб

Вс

{calendar.map((week) => week.map((day) => ( )) )}
); }; export default CalendarComponent;