Skip to content

Commit

Permalink
[WEB] Show all publisher books on publisher page
Browse files Browse the repository at this point in the history
  • Loading branch information
samtgarson committed Mar 14, 2024
1 parent aee3964 commit 7f051da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
10 changes: 2 additions & 8 deletions web/src/app/(main)/publishers/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export async function generateMetadata({

export * from 'app/default-static-config'

export default async ({
params: { slug },
searchParams: { page }
}: PublisherPageProps) => {
export default async ({ params: { slug } }: PublisherPageProps) => {
const [{ data: publisher }, { data: promo }] = await Promise.all([
call(fetchPublisher, { slug }),
call(fetchPromo, { publisherSlug: slug })
Expand All @@ -66,10 +63,7 @@ export default async ({
</Container>
<Container className="mt-8 sm:mt-20">
<Suspense fallback={<SkeletonPublisherBookList />}>
<PublisherBookList
publisher={publisher}
page={parseInt(`${page}`) || 0}
/>
<PublisherBookList publisher={publisher} />
</Suspense>
<div className="py-8 md:py-20">
{publisher.house && (
Expand Down
37 changes: 15 additions & 22 deletions web/src/components/publishers/book-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { fetchBooks } from '@books-about-food/core/services/books/fetch-books'
import { SkeletonBookList } from 'src/components/books/list'
import { GridContainer } from 'src/components/lists/grid-container'
import { ListContainer } from 'src/components/lists/list-context'
import { Pagination } from 'src/components/lists/pagination'
import { Wrap } from 'src/components/utils/wrap'
import { call } from 'src/utils/service'
import { PublisherBookListItem } from './item'
Expand All @@ -13,34 +12,28 @@ type PublisherBookListProps = {
page?: number
}

export async function PublisherBookList({
publisher,
page = 0
}: PublisherBookListProps) {
export async function PublisherBookList({ publisher }: PublisherBookListProps) {
const { data } = await call(fetchBooks, {
publisherSlug: publisher.slug,
perPage: 12,
page
perPage: 0
})

if (!data?.total) return null
const { books, ...pagination } = data
const { books } = data
return (
<ListContainer title="All Releases">
<Pagination {...pagination} page={page}>
<GridContainer className={'sm:gap-y-16'}>
{books.map((book) => {
return (
<Wrap
c={PublisherBookListItem}
key={book.id}
hidden={publisher.hiddenBooks.includes(book.id)}
book={book}
/>
)
})}
</GridContainer>
</Pagination>
<GridContainer className={'sm:gap-y-16'}>
{books.map((book) => {
return (
<Wrap
c={PublisherBookListItem}
key={book.id}
hidden={publisher.hiddenBooks.includes(book.id)}
book={book}
/>
)
})}
</GridContainer>
</ListContainer>
)
}
Expand Down

0 comments on commit 7f051da

Please sign in to comment.