-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from UTDNebula/JUP-61-club-search-page
feature: club search page
- Loading branch information
Showing
4 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use client'; | ||
import { api } from '@src/trpc/react'; | ||
import type { SelectClub as Club } from '@src/server/db/models'; | ||
import { type Session } from 'next-auth'; | ||
import ClubCard from '@src/components/club/ClubCard'; | ||
|
||
interface ClubSearchComponentProps { | ||
userSearch: string; | ||
session: Session | null; | ||
} | ||
|
||
export const ClubSearchComponent = ({ | ||
userSearch, | ||
session, | ||
}: ClubSearchComponentProps) => { | ||
const { data } = api.club.byNameNoLimit.useQuery( | ||
{ name: userSearch }, | ||
{ enabled: !!userSearch }, | ||
); | ||
|
||
if (!data) { | ||
return <p />; | ||
} | ||
if (data.length === 0) { | ||
return <p>No results found</p>; | ||
} | ||
|
||
return ( | ||
<div className="grid w-full auto-rows-fr grid-cols-[repeat(auto-fill,320px)] justify-center gap-16 pb-4"> | ||
{data.map((club: Club) => ( | ||
<ClubCard key={club.id} club={club} session={session} priority /> | ||
))} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Header from '@src/components/header/BaseHeader'; | ||
import { ClubSearchComponent } from './ClubSearch'; | ||
import { getServerAuthSession } from '@src/server/auth'; | ||
|
||
type Params = { | ||
searchParams: { [key: string]: string | undefined }; | ||
}; | ||
|
||
const clubSearch = async (props: Params) => { | ||
const { searchParams } = props; | ||
const userSearch = searchParams['search'] || ''; | ||
const session = await getServerAuthSession(); | ||
|
||
return ( | ||
<main className="md:pl-72"> | ||
<div> | ||
<Header /> | ||
<ClubSearchComponent userSearch={userSearch} session={session} /> | ||
</div> | ||
</main> | ||
); | ||
}; | ||
|
||
export default clubSearch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters