import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { supabase } from '@/integrations/supabase/client'; import { AppLayout } from '@/components/AppLayout'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Skeleton } from '@/components/ui/skeleton'; import { formatDateTime } from '@/lib/format'; import { Calendar, Video, Users, BookOpen } from 'lucide-react'; interface Event { id: string; type: string; product_id: string | null; title: string; starts_at: string; ends_at: string; status: string; product?: { slug: string; title: string; } | null; } export default function Events() { const [events, setEvents] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetchEvents(); }, []); const fetchEvents = async () => { const { data, error } = await supabase .from('events') .select(` *, product:products (slug, title) `) .eq('status', 'confirmed') .gte('ends_at', new Date().toISOString()) .order('starts_at', { ascending: true }); if (!error && data) { setEvents(data as unknown as Event[]); } setLoading(false); }; const getTypeIcon = (type: string) => { switch (type) { case 'bootcamp': return BookOpen; case 'webinar': return Video; case 'consulting': return Users; default: return Calendar; } }; const getTypeLabel = (type: string) => { switch (type) { case 'bootcamp': return 'Bootcamp'; case 'webinar': return 'Webinar'; case 'consulting': return 'Konsultasi'; default: return type; } }; return (

Kalender Acara

Jadwal webinar, bootcamp, dan sesi konsultasi

{loading ? (
{[...Array(3)].map((_, i) => ( ))}
) : events.length === 0 ? (

Belum ada acara terjadwal

) : (
{events.map((event) => { const Icon = getTypeIcon(event.type); return (
{event.title} {formatDateTime(event.starts_at)}
{getTypeLabel(event.type)}
{event.product && ( )}
); })}
)}
); }