diff --git a/src/components/DateCalendarPopup.jsx b/src/components/DateCalendarPopup.jsx new file mode 100644 index 0000000..cbf2887 --- /dev/null +++ b/src/components/DateCalendarPopup.jsx @@ -0,0 +1,50 @@ +import { useState, useEffect, useRef } from "react"; + +const MONTHS = ["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"]; +const DAYS = ["Пн","Вт","Ср","Чт","Пт","Сб","Вс"]; + +export default function DateCalendarPopup({ date, onClose }) { + const ref = useRef(null); + const d = new Date(date); + const [year, setYear] = useState(d.getFullYear()); + const [month, setMonth] = useState(d.getMonth()); + + useEffect(() => { + const handler = (e) => { if (ref.current && !ref.current.contains(e.target)) onClose(); }; + document.addEventListener("mousedown", handler); + return () => document.removeEventListener("mousedown", handler); + }, [onClose]); + + const firstDay = new Date(year, month, 1).getDay(); + const offset = firstDay === 0 ? 6 : firstDay - 1; + const daysInMonth = new Date(year, month + 1, 0).getDate(); + + const cells = []; + for (let i = 0; i < offset; i++) cells.push(null); + for (let i = 1; i <= daysInMonth; i++) cells.push(i); + + const isSameDay = (day) => + d.getFullYear() === year && d.getMonth() === month && d.getDate() === day; + + return ( +
+
+ + {MONTHS[month]} {year} + +
+
+ {DAYS.map(d =>
{d}
)} + {cells.map((day, i) => + day ? ( +
+ {day} +
+ ) :
+ )} +
+
+ ); +} diff --git a/src/components/MainFeed.jsx b/src/components/MainFeed.jsx index 3413ee8..39d587f 100644 --- a/src/components/MainFeed.jsx +++ b/src/components/MainFeed.jsx @@ -441,13 +441,6 @@ export default function MainFeed() { {/* Фильтр по типу объявления */}
- +
-
{ad.title}
+
+ {ad.title} + {isClosed && ✓ Найдено} +
{ad.description}
{/* ✅ address вместо ad.location */} {address &&
{address}
} - {/* ✅ createdAt вместо ad.date */} - {createdAt &&
{createdAt}
} + {createdAt && ( +
{ e.stopPropagation(); setShowCalendar(s => !s); }}> + {createdAt} + {showCalendar && setShowCalendar(false)} />} +
+ )}
{address && (