diff --git a/src/routes/events/index.tsx b/src/routes/events/index.tsx index b834045..2bc316f 100644 --- a/src/routes/events/index.tsx +++ b/src/routes/events/index.tsx @@ -1,51 +1,82 @@ import { createFileRoute } from '@tanstack/react-router'; -import { Clock } from "flowbite-react-icons/solid"; +import { Clock, Search } from "flowbite-react-icons/outline"; +import { useState } from 'react'; import { BellIcon, Header, PinIcon, PlusIcon } from '../../components'; import { AuthGuard } from '../../utils/auth'; import { supabase } from '../../utils/supabase'; + interface Event { - created_at: string; - description: string | null; - end_time: string | null; - fee: number | null; - id: number; - name: string | null; - start_time: string | null; - type: number | null; - user_id: string; - location: string | null; + created_at: string; + description: string | null; + end_time: string | null; + fee: number | null; + id: number; + name: string | null; + start_time: string | null; + type: number | null; + user_id: string; + location: string | null; } export const Route = createFileRoute('/events/')({ beforeLoad: AuthGuard, loader: async () => { - const { data, error } = await supabase - .from('events') - .select('*') + const { data, error } = await supabase.from('events').select('*'); if (error !== null) { - throw error + throw error; } - return { events: data } + return { events: data }; }, - component: EventIndex -}) + component: EventIndex, +}); function EventIndex() { - const { events } = Route.useLoaderData() + const { events } = Route.useLoaderData(); const navigate = Route.useNavigate(); - // console.log(events[0].start_time) + const [searchTerm, setSearchTerm] = useState(''); + const [isFocused, setIsFocused] = useState(false); + + const filteredEvents = events.filter( + (event) => + event.name && + event.name.toLowerCase().includes(searchTerm.toLowerCase()) + ); return ( <>