-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
244 additions
and
31 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
# Briskly | ||
|
||
![Briskly! Your AI powered flashcards app.](/docs/images/banner.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { InView } from 'react-intersection-observer' | ||
|
||
import type { GetServerSideProps, InferGetServerSidePropsType } from 'next' | ||
import { type NextPage } from 'next' | ||
import Head from 'next/head' | ||
|
||
import { DeckCardList } from '~/components/deck-card-list' | ||
import { Loader } from '~/components/loader' | ||
import { api } from '~/utils/api' | ||
|
||
export const getServerSideProps: GetServerSideProps<{ | ||
searchedTerm: string | ||
}> = async context => { | ||
const searchedTerm = context.params?.term as string | ||
|
||
if (!searchedTerm) return { notFound: true } | ||
|
||
return { | ||
props: { | ||
searchedTerm, | ||
}, | ||
} | ||
} | ||
|
||
const SearchDecksPage: NextPage< | ||
InferGetServerSidePropsType<typeof getServerSideProps> | ||
> = props => { | ||
const { searchedTerm } = props | ||
|
||
const { | ||
data, | ||
isError, | ||
refetch, | ||
isLoading, | ||
hasNextPage, | ||
fetchNextPage, | ||
isFetchingNextPage, | ||
} = api.decks.searchByTerm.useInfiniteQuery( | ||
{ term: searchedTerm }, | ||
{ | ||
getNextPageParam: lastPage => lastPage.nextCursor, | ||
keepPreviousData: true, | ||
}, | ||
) | ||
|
||
const decks = data?.pages.flatMap(page => page.decks) ?? [] | ||
const hasLoadedDecks = decks.length > 0 | ||
|
||
const renderContent = () => { | ||
if (isLoading) return <DeckCardList.Loading /> | ||
|
||
if (!hasLoadedDecks && isError) { | ||
return <DeckCardList.Error onRetryPress={refetch} /> | ||
} | ||
|
||
return <DeckCardList decks={decks} /> | ||
} | ||
|
||
return ( | ||
<> | ||
<Head> | ||
<title>{`Decks sobre ${searchedTerm}`}</title> | ||
<meta | ||
name='description' | ||
content={`Uma lista completa de decks sobre ${searchedTerm}`} | ||
/> | ||
</Head> | ||
<h1 className='mb-5 text-2xl font-semibold'>{`Resultados para "${searchedTerm}"`}</h1> | ||
<div className='flex flex-col items-center'> | ||
{renderContent()} | ||
<InView | ||
as='div' | ||
className='mt-5 flex w-full items-center justify-center' | ||
onChange={inView => { | ||
if (inView && hasNextPage && !isError && !isFetchingNextPage) { | ||
fetchNextPage() | ||
} | ||
}} | ||
> | ||
{isFetchingNextPage ? <Loader /> : null} | ||
</InView> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default SearchDecksPage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { atom } from 'jotai' | ||
|
||
export const fullScreenLoaderAtom = atom(false) | ||
export const isHeaderSearchInputVisibleAtom = atom(false) |
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
Oops, something went wrong.
26893c5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
briskly β ./
briskly-emiliosheinz.vercel.app
briskly.app
briskly-git-main-emiliosheinz.vercel.app