@@ -2,11 +2,13 @@ import { ReactNode } from 'react';
22
33import { Stream , Streamable } from '@/vibes/soul/lib/streamable' ;
44import { Accordion , AccordionItem } from '@/vibes/soul/primitives/accordion' ;
5+ import { AnimatedUnderline } from '@/vibes/soul/primitives/animated-underline' ;
56import { Price , PriceLabel } from '@/vibes/soul/primitives/price-label' ;
67import { Rating } from '@/vibes/soul/primitives/rating' ;
78import * as Skeleton from '@/vibes/soul/primitives/skeleton' ;
89import { type Breadcrumb , Breadcrumbs } from '@/vibes/soul/sections/breadcrumbs' ;
910import { ProductGallery } from '@/vibes/soul/sections/product-detail/product-gallery' ;
11+ import { ReviewForm , SubmitReviewAction } from '@/vibes/soul/sections/reviews/review-form' ;
1012
1113import { ProductDetailForm , ProductDetailFormAction } from './product-detail-form' ;
1214import { Field } from './schema' ;
@@ -21,6 +23,7 @@ interface ProductDetailProduct {
2123 badge ?: string ;
2224 rating ?: Streamable < number | null > ;
2325 reviewsEnabled ?: boolean ;
26+ showRating ?: boolean ;
2427 summary ?: Streamable < string > ;
2528 description ?: Streamable < string | ReactNode | null > ;
2629 accordions ?: Streamable <
@@ -49,6 +52,15 @@ export interface ProductDetailProps<F extends Field> {
4952 thumbnailLabel ?: string ;
5053 additionalInformationTitle ?: string ;
5154 additionalActions ?: ReactNode ;
55+ reviewFormEmailLabel ?: string ;
56+ reviewFormModalTitle ?: string ;
57+ reviewFormNameLabel ?: string ;
58+ reviewFormRatingLabel ?: string ;
59+ reviewFormReviewLabel ?: string ;
60+ reviewFormSubmitLabel ?: string ;
61+ reviewFormTitleLabel ?: string ;
62+ reviewFormAction : SubmitReviewAction ;
63+ user : Streamable < { email : string ; name : string } > ;
5264}
5365
5466// eslint-disable-next-line valid-jsdoc
@@ -81,6 +93,15 @@ export function ProductDetail<F extends Field>({
8193 thumbnailLabel,
8294 additionalInformationTitle = 'Additional information' ,
8395 additionalActions,
96+ reviewFormEmailLabel,
97+ reviewFormModalTitle,
98+ reviewFormNameLabel,
99+ reviewFormRatingLabel,
100+ reviewFormReviewLabel,
101+ reviewFormSubmitLabel,
102+ reviewFormTitleLabel,
103+ reviewFormAction,
104+ user,
84105} : ProductDetailProps < F > ) {
85106 return (
86107 < section className = "@container" >
@@ -110,6 +131,29 @@ export function ProductDetail<F extends Field>({
110131 { product . title }
111132 </ h1 >
112133 { product . reviewsEnabled && (
134+ < div className = "group/product-rating" >
135+ < ReviewForm
136+ action = { reviewFormAction }
137+ formEmailLabel = { reviewFormEmailLabel }
138+ formModalTitle = { reviewFormModalTitle }
139+ formNameLabel = { reviewFormNameLabel }
140+ formRatingLabel = { reviewFormRatingLabel }
141+ formReviewLabel = { reviewFormReviewLabel }
142+ formSubmitLabel = { reviewFormSubmitLabel }
143+ formTitleLabel = { reviewFormTitleLabel }
144+ productId = { Number ( product . id ) }
145+ streamableImages = { product . images }
146+ streamableProduct = { { name : product . title } }
147+ streamableUser = { user }
148+ trigger = {
149+ < AnimatedUnderline className = "cursor-pointer" >
150+ Write a review
151+ </ AnimatedUnderline >
152+ }
153+ />
154+ </ div >
155+ ) }
156+ { product . showRating && (
113157 < div className = "group/product-rating" >
114158 < Stream fallback = { < RatingSkeleton /> } value = { product . rating } >
115159 { ( rating ) => < Rating rating = { rating ?? 0 } /> }
0 commit comments