Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjoelson committed Oct 22, 2024
1 parent 08b0516 commit 20dbe60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/app/events/search/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// app/search/page.tsx
import SearchResults from '@src/components/SearchResults';

const SearchPage = () => {
return <SearchResults />;
};

export default SearchPage;
21 changes: 16 additions & 5 deletions src/components/SearchResults.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { api } from '@src/trpc/server';
import EventCard from '@src/components/events/EventCard';
import { useEffect, useState } from 'react';
import { useSearchParams } from 'next/navigation';
import EventCard from '@src/components/events/EventCard';
import { api } from '@src/trpc/react';

const SearchResults = async () => {
const SearchResults = () => {
const searchParams = useSearchParams();
const query = searchParams.get('query') || '';
const [events, setEvents] = useState([]);

useEffect(() => {
const fetchEvents = async () => {
const { data } = await api.event.searchByName.useQuery({ name: query });
setEvents(data || []);
};

const { events } = await api.event.searchByName({ name: query });
if (query) {
fetchEvents();
}
}, [query]);

return (
<main className="pb-10 md:pl-72">
<h1 className="text-2xl font-bold">Search Results for "{query}"</h1>
<h1 className="text-2xl font-bold">Events</h1>
<div className="flex flex-col space-y-4">
{events.length > 0 ? (
events.map((event) => <EventCard key={event.id} event={event} />)
Expand Down

0 comments on commit 20dbe60

Please sign in to comment.