'use client' import { useState, useEffect, useMemo } from 'react' import { ChevronLeft, ChevronRight, Plus, X, Clock, MapPin, Trash2, Eye, EyeOff, CalendarDays, User, AlignLeft, List } from 'lucide-react' interface CalendarEvent { id: string title: string start: string end: string allDay: boolean description: string | null location: string | null owner: string ownerName: string color: string } const WEEKDAYS = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'] const MONTHS = ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'] function formatTime(iso: string): string { return new Date(iso).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' }) } function formatFullDate(iso: string): string { return new Date(iso).toLocaleDateString('ru-RU', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' }) } // ————— Add Event Modal ————— const CALENDAR_OPTIONS = [ { owner: 'daniil', name: 'Даниил', color: '#6366f1' }, { owner: 'sveta', name: 'Света', color: '#ec4899' }, ] function AddEventModal({ defaultDate, onClose, onSaved }: { defaultDate: string; onClose: () => void; onSaved: (e: any) => void }) { const [title, setTitle] = useState('') const [date, setDate] = useState(defaultDate) const [startTime, setStartTime] = useState('10:00') const [endTime, setEndTime] = useState('11:00') const [allDay, setAllDay] = useState(false) const [owner, setOwner] = useState('daniil') const [saving, setSaving] = useState(false) const [error, setError] = useState('') const selectedCal = CALENDAR_OPTIONS.find(c => c.owner === owner) || CALENDAR_OPTIONS[0] const save = async () => { if (!title.trim()) { setError('Введите название'); return } setSaving(true); setError('') try { const body = { title: title.trim(), date, startTime: allDay ? null : startTime, endTime: allDay ? null : endTime, allDay, owner } const r = await fetch('/api/calendar', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }) const d = await r.json() if (d.error) throw new Error(d.error) onSaved(d.event) } catch (e: any) { setError(e.message || 'Ошибка сохранения'); setSaving(false) } } return (