-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added pagination and performance updates
- Loading branch information
1 parent
1f2c4bf
commit 59e4f49
Showing
9 changed files
with
165 additions
and
65 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,5 @@ | ||
--- | ||
"@bigcommerce/catalyst-core": patch | ||
--- | ||
|
||
add wishlist book |
23 changes: 21 additions & 2 deletions
23
core/app/[locale]/(default)/account/[tab]/_actions/delete-wishlists.ts
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,12 +1,31 @@ | ||
'use server'; | ||
|
||
import { revalidatePath } from 'next/cache'; | ||
|
||
import { | ||
deleteWishlists as deleteWishlistsClient, | ||
Input, | ||
} from '~/client/mutations/delete-wishlists'; | ||
|
||
export const deleteWishlists = async (wishlists: Input) => { | ||
const result = await deleteWishlistsClient(wishlists); | ||
try { | ||
const result = await deleteWishlistsClient(wishlists); | ||
|
||
revalidatePath('/account/wishlists', 'page'); | ||
|
||
if (result === 'success') { | ||
return { | ||
status: 'success', | ||
}; | ||
} | ||
} catch (error: unknown) { | ||
if (error instanceof Error) { | ||
return { | ||
status: 'error', | ||
message: error.message, | ||
}; | ||
} | ||
} | ||
|
||
return result; | ||
return { status: 'error', message: 'Unknown error.' }; | ||
}; |
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
32 changes: 26 additions & 6 deletions
32
core/app/[locale]/(default)/account/[tab]/_components/wishlist-content/index.tsx
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,24 +1,44 @@ | ||
interface Props { | ||
wishlists: Wishlists; | ||
} | ||
import { getLocale, getTranslations } from 'next-intl/server'; | ||
|
||
import { Pagination } from '../../../../(faceted)/_components/pagination'; | ||
import { getWishlistQuery } from '../../page-data'; | ||
import { TabHeading } from '../tab-heading'; | ||
|
||
import { WishlistBook } from './wishlist-book'; | ||
|
||
export type Wishlists = NonNullable<Awaited<ReturnType<typeof getWishlistQuery>>>; | ||
type WishlistsDetails = NonNullable<Awaited<ReturnType<typeof getWishlistQuery>>>; | ||
export type Wishlists = WishlistsDetails['wishlists']; | ||
|
||
interface Props { | ||
wishlists: Wishlists; | ||
pageInfo: WishlistsDetails['pageInfo']; | ||
} | ||
|
||
export interface FormStatus { | ||
status: 'success' | 'error'; | ||
message: string; | ||
} | ||
|
||
export const WishlistContent = ({ wishlists }: Props) => { | ||
export const WISHLISTS_PER_PAGE = 4; | ||
|
||
export const WishlistContent = async ({ pageInfo, wishlists }: Props) => { | ||
const locale = await getLocale(); | ||
const t = await getTranslations({ locale, namespace: 'Pagination' }); | ||
|
||
const { hasNextPage, hasPreviousPage, startCursor, endCursor } = pageInfo; | ||
|
||
return ( | ||
<> | ||
<TabHeading heading="wishlists" /> | ||
<WishlistBook wishlists={wishlists} /> | ||
<WishlistBook hasPreviousPage={hasPreviousPage} key={endCursor} wishlists={wishlists} /> | ||
<Pagination | ||
endCursor={endCursor} | ||
hasNextPage={hasNextPage} | ||
hasPreviousPage={hasPreviousPage} | ||
nextLabel={t('next')} | ||
prevLabel={t('prev')} | ||
startCursor={startCursor} | ||
/> | ||
</> | ||
); | ||
}; |
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.