"use client"; import { User, X, MapPin } from "lucide-react"; import { shortAddress } from "./constants"; import type { ScheduleDayMerged, ScheduleClassWithLocation } from "./constants"; interface MobileScheduleProps { typeDots: Record; filteredDays: ScheduleDayMerged[]; filterTypes: Set; toggleFilterType: (type: string) => void; filterTrainer: string | null; setFilterTrainer: (trainer: string | null) => void; hasActiveFilter: boolean; clearFilters: () => void; showLocation?: boolean; } function ClassRow({ cls, typeDots, filterTypes, toggleFilterType, filterTrainer, setFilterTrainer, showLocation, }: { cls: ScheduleClassWithLocation; typeDots: Record; filterTypes: Set; toggleFilterType: (type: string) => void; filterTrainer: string | null; setFilterTrainer: (trainer: string | null) => void; showLocation?: boolean; }) { return (
{/* Time */} {cls.time} {/* Info — tappable trainer & type */}
{cls.hasSlots && ( места )} {cls.recruiting && ( набор )} {cls.level && ( {cls.level} )}
{showLocation && cls.locationName && ( {cls.locationName} )}
); } export function MobileSchedule({ typeDots, filteredDays, filterTypes, toggleFilterType, filterTrainer, setFilterTrainer, hasActiveFilter, clearFilters, showLocation, }: MobileScheduleProps) { return (
{/* Active filter indicator */} {hasActiveFilter && (
{filterTrainer && ( {filterTrainer} )} {filterTypes.size > 0 && Array.from(filterTypes).map((type) => ( {type} ))}
)} {filteredDays.length > 0 ? (
{filteredDays.map((day) => { // Group classes by location when showLocation is true const locationGroups = showLocation ? Array.from( day.classes.reduce((map, cls) => { const loc = cls.locationName ?? ""; if (!map.has(loc)) { map.set(loc, { address: cls.locationAddress, classes: [] }); } map.get(loc)!.classes.push(cls); return map; }, new Map()) ) : null; return (
{/* Day header */}
{day.dayShort} {day.day}
{/* Class rows */}
{locationGroups ? ( // Split by location locationGroups.map(([locName, { address, classes }]) => (
{/* Location sub-header */}
{locName} {address && · {shortAddress(address)}}
{classes.map((cls, i) => ( ))}
)) ) : ( // Single location — no sub-headers day.classes.map((cls, i) => ( )) )}
); })}
) : (
Нет занятий по выбранным фильтрам
)}
); }