-
Notifications
You must be signed in to change notification settings - Fork 0
feat: multi-page structure with React Router #12
Merged
+525
−509
Merged
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
37a64e2
feat!: restructure to use multiple pages and search params
martakam d6f4a63
fix: adjust look of BookCard
martakam efe3be2
test: remove "works" prefix from openLibrary tests
martakam 1c62ee2
chore: remove unused files
martakam 1b352e8
test: check for new linking in BookCard
martakam a30092b
test: new pagination in search params
martakam 2b6a41c
test: search bar query from URL
martakam 2ad7e6c
test: adjust to new SelectedBookPage with search params
martakam 4f42bff
test: adjust HomePage test to use URL search params
martakam 0aa02d4
Merge branch 'main' into feat/multi-page-structure
martakam b120f4a
fix: do not remove search params when clicking back button
martakam 143aeb2
fix: remove button in BookCard and style link directly
martakam 8218894
fix: do not set query to empty string
martakam 1198d67
fix: style back and next book buttons correctly
martakam 7579660
fix: use filters correctly when selecting a book
martakam 2716088
feat: show loading book details info text with proper styling
martakam 73a4caa
fix: use debounce for book filters
martakam bc18083
fix: remove duplicate language codes
martakam 3619b09
fix: always include searchParams even when link is disabled
martakam 998f638
fix: always use "search" for searchParams in Link components
martakam 5cbc4f1
fix: use new searchParams from URL immediately on URL change
martakam ce53c81
test: adjust to new button name and update snapshot
martakam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,25 @@ | ||
| import { useSearchParams } from "react-router"; | ||
|
|
||
| function useBookSearchParams() { | ||
| const [searchParams] = useSearchParams(); | ||
|
|
||
| const rawQuery = searchParams.get("q") ?? ""; | ||
| const page = parseInt(searchParams.get("page") ?? "1", 10); | ||
| const filters = { | ||
| author: searchParams.get("author") ?? undefined, | ||
| subject: searchParams.get("subject") ?? undefined, | ||
| place: searchParams.get("place") ?? undefined, | ||
| person: searchParams.get("person") ?? undefined, | ||
| language: searchParams.get("language") ?? undefined, | ||
| publisher: searchParams.get("publisher") ?? undefined, | ||
| }; | ||
|
|
||
| const hasFilters = | ||
| Object.values(filters).filter((value) => value !== undefined).length > 0; | ||
|
|
||
| const query = rawQuery || hasFilters ? rawQuery : "subject:fantasy"; | ||
|
|
||
| return { rawQuery, query, page, filters }; | ||
| } | ||
|
|
||
| export { useBookSearchParams }; |
File renamed without changes.
This file contains hidden or 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,11 @@ | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { fetchWork } from "~/api/openLibrary"; | ||
|
|
||
| function useWork(key: string) { | ||
| return useQuery({ | ||
| queryKey: ["work", key], | ||
| queryFn: () => fetchWork(key), | ||
| }); | ||
| } | ||
|
|
||
| export { useWork }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.