import React from "react"; import { Button } from "../UI/Button"; const WEEK_DAY_LABELS = ["ПН", "ВТ", "СР", "ЧТ", "ПТ", "СБ", "ВС"]; const toDateKey = (date) => { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, "0"); const day = String(date.getDate()).padStart(2, "0"); return `${year}-${month}-${day}`; }; const isWeekendDate = (date) => { const day = date.getDay(); return day === 0 || day === 6; }; const isSelectableCalendarDate = (date, minDateKey) => { const dateKey = toDateKey(date); return dateKey >= minDateKey && !isWeekendDate(date); }; const formatDateForDisplay = (value) => { if (!value) { return "Выберите дату"; } const [year, month, day] = value.split("-").map(Number); if (!year || !month || !day) { return value; } return new Date(year, month - 1, day).toLocaleDateString("ru-RU", { day: "2-digit", month: "2-digit", year: "numeric", }); }; const CalendarWidget = ({ label, selectedDate, onDateChange, minDateKey, isCalendarOpen, setIsCalendarOpen, currentMonth, setCurrentMonth, calendarDays, monthLabel, canGoBack, timeOptions, selectedTime, onTimeChange, layoutClassName, calendarClassName, timeClassName, }) => { return (
{isCalendarOpen ? (

{label}

{monthLabel}

{WEEK_DAY_LABELS.map((day) => (
{day}
))}
{calendarDays.map((day, index) => { if (!day) { return
; } const dateKey = toDateKey(day); const isWeekend = isWeekendDate(day); const isSelectable = isSelectableCalendarDate(day, minDateKey); const isSelected = dateKey === selectedDate; const isDisabled = !isSelectable; const dayNumber = String(day.getDate()).padStart(2, "0"); return ( ); })}

Выходные отмечены пунктиром и недоступны.

) : null}
{timeOptions.map((option) => ( ))}
); }; export { CalendarWidget, formatDateForDisplay };