-
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.
SUP-197 SUP-182 Stubbed out search and file list components (#6)
- Loading branch information
Showing
29 changed files
with
1,171 additions
and
490 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,27 @@ | ||
import {BooksQuery} from "@lib/gql/__generated__/drupal"; | ||
import {graphqlClient} from "@lib/gql/gql-client"; | ||
import {notFound, redirect} from "next/navigation"; | ||
|
||
const LegacyBookPage = async ({searchParams}: { searchParams?: { [_key: string]: string } }) => { | ||
// Fetch all the books, sort by authors, and then build pagination and side alpha selection. | ||
let fetchMore = true; | ||
let query: BooksQuery; | ||
let afterCursor = null; | ||
let destinationUrl: string | undefined; | ||
|
||
if (!searchParams || !searchParams.id) notFound(); | ||
const workId = parseInt(searchParams.id); | ||
|
||
while (fetchMore) { | ||
query = await graphqlClient({next: {tags: ["views:sup_books"]}}).Books({after: afterCursor}) | ||
|
||
destinationUrl = query.nodeSupBooks.nodes.find(node => node.supBookWorkIdNumber && node.supBookWorkIdNumber === workId)?.path; | ||
|
||
fetchMore = query.nodeSupBooks.pageInfo.hasNextPage && !destinationUrl | ||
afterCursor = query.nodeSupBooks.pageInfo.endCursor; | ||
} | ||
if (destinationUrl) redirect(destinationUrl); | ||
notFound(); | ||
} | ||
|
||
export default LegacyBookPage; |
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
Oops, something went wrong.