import { ReactNode, useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' import Icon from '../components/Icon' import { useNow } from '../hooks/useNow' import { CafeSchedule, fetchCafeSchedules } from '../services/campaignApi' import { getCafeUuid } from '../utils/cafe' import HostBanner from '../assets/images/banners/Host-banner.jpg' import { formatPersianNumber } from '../utils/formatNumber' import { formatMatchLabel } from '../utils/matchCountdown' function PanelRow({ icon, label, onClick }: { icon: ReactNode; label: string; onClick?: () => void }) { return ( ) } export default function CafeOwnerPanel() { const navigate = useNavigate() const now = useNow() const [schedules, setSchedules] = useState([]) useEffect(() => { const cafeUuid = getCafeUuid() if (!cafeUuid) return fetchCafeSchedules(cafeUuid) .then(setSchedules) .catch(() => {}) }, []) return (

پنل کافه

} label="اطلاعات کافه" onClick={() => navigate('/owner/register', { state: { step: 2 } })} /> } label="افزودن رویداد" onClick={() => navigate('/owner/events/new')} />

رویدادهای فعال شما

{schedules.map((schedule) => { const isPast = new Date(schedule.match_event.match_datetime).getTime() <= now.getTime() const matchLabel = formatMatchLabel(schedule.match_event, now) return (

{matchLabel}

{isPast && ( برگزار شده )}
{formatPersianNumber(schedule.remaining_tickets)} صندلی از {formatPersianNumber(schedule.total_tickets)} باقی مانده
} label="مشاهده رزروها" onClick={() => navigate(`/owner/events/${schedule.uuid}/reservations`, { state: { event: { id: schedule.uuid, matchLabel, remainingSeats: schedule.remaining_tickets, totalSeats: schedule.total_tickets, }, }, }) } />
) })}
) }