Repository navigation
Feat/herbatica review #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
70ab570
chore: update AGENTS files
KaiUweCZE 55c2b6c
feat(storefront-data): add product review data support
KaiUweCZE 2c327c8
feat(herbatika): show product reviews on PDP
KaiUweCZE 4ffe2de
feat: add review
KaiUweCZE 109f2cd
fix: harden product review pagination
KaiUweCZE 6fa6978
merge master into feat/herbatica-review and fix conflict
KaiUweCZE 52c4836
fix(herbatika): align UI token overrides with updated ui-kit tokens
KaiUweCZE b902815
feat(herbatika): add product review token flow
KaiUweCZE 61611b3
fix: remove review title
KaiUweCZE 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { ProductReviewTokenPage } from "@/components/reviews/product-review-token-page"; | ||
|
|
||
| type ProductReviewTokenRouteProps = { | ||
| params: Promise<{ | ||
| token: string; | ||
| }>; | ||
| searchParams: Promise<{ | ||
| product_id?: string | string[]; | ||
| }>; | ||
| }; | ||
|
|
||
| const resolveSearchParam = (value?: string | string[]) => | ||
| Array.isArray(value) ? value[0] : value; | ||
|
|
||
| export const metadata = { | ||
| title: "Napísať recenziu | Herbatica", | ||
| }; | ||
|
|
||
| export default async function ProductReviewTokenRoute({ | ||
| params, | ||
| searchParams, | ||
| }: ProductReviewTokenRouteProps) { | ||
| const [{ token }, resolvedSearchParams] = await Promise.all([ | ||
| params, | ||
| searchParams, | ||
| ]); | ||
|
|
||
| return ( | ||
| <ProductReviewTokenPage | ||
| productId={resolveSearchParam(resolvedSearchParams.product_id)} | ||
| token={token} | ||
| /> | ||
| ); | ||
| } |
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
79 changes: 74 additions & 5 deletions
79
apps/herbatika/src/components/product-detail/sections/product-detail-metrics.tsx
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 |
|---|---|---|
| @@ -1,9 +1,78 @@ | ||
| "use client" | ||
| "use client"; | ||
|
|
||
| import { ReviewsSection } from "@/components/reviews/reviews-section" | ||
| import { ReviewSkeleton } from "@/components/loading/review-skeleton"; | ||
| import { | ||
| formatReviewScore, | ||
| PRODUCT_DETAIL_REVIEWS_SECTION_ID, | ||
| toReviewItem, | ||
| } from "@/components/product-detail/sections/product-detail-review-utils"; | ||
| import { ReviewsSection } from "@/components/reviews/reviews-section"; | ||
| import { | ||
| PRODUCT_REVIEWS_PAGE_SIZE, | ||
| useProductReviews, | ||
| } from "@/lib/storefront/reviews"; | ||
|
|
||
| type ProductDetailMetricsProps = { | ||
| onShowAllReviews?: () => void; | ||
| productId?: string | null; | ||
| }; | ||
|
|
||
| const PRODUCT_REVIEW_TEASER_LIMIT = 4; | ||
|
|
||
| function ProductDetailMetricsSkeleton() { | ||
| return ( | ||
| <section className="space-y-500 pt-750"> | ||
| <div className="grid grid-cols-1 gap-500 md:grid-cols-2 xl:grid-cols-4"> | ||
| {Array.from({ length: PRODUCT_REVIEW_TEASER_LIMIT }, (_, index) => ( | ||
| <ReviewSkeleton key={`product-review-teaser-skeleton-${index + 1}`} /> | ||
| ))} | ||
| </div> | ||
| </section> | ||
| ); | ||
| } | ||
|
|
||
| export function ProductDetailMetrics({ | ||
| onShowAllReviews, | ||
| productId, | ||
| }: ProductDetailMetricsProps) { | ||
| const reviewsQuery = useProductReviews({ | ||
| enabled: Boolean(productId), | ||
| limit: PRODUCT_REVIEWS_PAGE_SIZE, | ||
| offset: 0, | ||
| productId: productId ?? undefined, | ||
| }); | ||
| const reviews = reviewsQuery.reviews | ||
| .slice(0, PRODUCT_REVIEW_TEASER_LIMIT) | ||
| .map(toReviewItem); | ||
|
|
||
| if (!productId) { | ||
| return null; | ||
| } | ||
|
|
||
| if (reviewsQuery.isLoading && reviews.length === 0) { | ||
| return <ProductDetailMetricsSkeleton />; | ||
| } | ||
|
|
||
| if (reviews.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| export function ProductDetailMetrics() { | ||
| return ( | ||
| <ReviewsSection sectionClassName="space-y-500 pt-750" variant="product" /> | ||
| ) | ||
| <ReviewsSection | ||
| linkHref={`#${PRODUCT_DETAIL_REVIEWS_SECTION_ID}`} | ||
| onLinkClick={(event) => { | ||
| if (!onShowAllReviews) { | ||
| return; | ||
| } | ||
|
|
||
| event.preventDefault(); | ||
| onShowAllReviews(); | ||
| }} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ratingValue={reviewsQuery.summary.average_rating} | ||
| reviews={reviews} | ||
| scoreLabel={formatReviewScore(reviewsQuery.summary.average_rating)} | ||
| sectionClassName="space-y-500 pt-750" | ||
| variant="product" | ||
| /> | ||
| ); | ||
| } | ||
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.