-
Notifications
You must be signed in to change notification settings - Fork 75
fix: declare RatingSummary in section components #2707
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
fix: declare RatingSummary in section components #2707
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
packages/core/src/components/sections/ReviewsAndRatings/DefaultComponents.ts
Outdated
Show resolved
Hide resolved
packages/core/src/components/sections/ReviewsAndRatings/DefaultComponents.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Fanny Chien <[email protected]>
Co-authored-by: Fanny Chien <[email protected]>
hellofanny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I notice that was some code related to modalReview, that probably is better to address separately in the next PR.
packages/core/src/components/ui/ReviewsAndRatings/ReviewsAndRatings.tsx
Outdated
Show resolved
Hide resolved
packages/core/src/components/ui/ReviewsAndRatings/ReviewsAndRatings.tsx
Outdated
Show resolved
Hide resolved
packages/core/src/components/ui/ReviewsAndRatings/ReviewsAndRatings.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Fanny Chien <[email protected]>
Co-authored-by: Fanny Chien <[email protected]>
| } | ||
| ReviewsAndRatings: { | ||
| Section: typeof ReviewsAndRatings | ||
| // TODO: Add components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is because we also need to add ReviewModal right?
>⚠️ THIS PR DEPENDS ON:⚠️ > - <del>https://github.com/vtex/faststore/pull/2693</del> (PR was closed because this one will suffice) > - #2707 ## What's the purpose of this pull request? This PR integrates the `ReviewModal` component in the core package for the Review and Ratings section. The actual review form implementation will be handled in a separate PR to be easy to review. ## How it works? - Adding schema configuration in sections.json for `ReviewModal` properties in the Headless CMS - Creating a new `ReviewModal` component in packages/core/src/components/reviews that will handle form logic - Integrating the modal within the ReviewsAndRatings UI with a temporary trigger button ## How to test it? - Check `ReviewModal` structure in core package and its types declarations - Confirm that CMS-configured content is properly displayed <!--- Describe the steps with bullet points. Is there any external link that can be used to better test it or an example? ---> ### Starters Deploy Preview [Preview](https://starter-git-feat-add-review-modal-core-structure-vtex.vercel.app/) <!--- Add a link to a deploy preview from `starter.store` with this branch being used. ---> <!--- Tip: You can get an installable version of this branch from the CodeSandbox generated when this PR is created. ---> ## References [FEATURE BRANCH](#2676) [Figma](https://www.figma.com/design/YXU6IX2htN2yg7udpCumZv/Reviews-%26-Ratings?node-id=128-22351&t=zALRZSwDWuF6UrjH-4) [SFS-2082](https://vtex-dev.atlassian.net/browse/SFS-2082) [SFS-2082]: https://vtex-dev.atlassian.net/browse/SFS-2082?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Fanny Chien <[email protected]> Co-authored-by: Bruno Guilera Gutchenzo <[email protected]> Co-authored-by: Fanny Chien <[email protected]>
>⚠️ THIS PR DEPENDS ON:⚠️ > - <del>https://github.com/vtex/faststore/pull/2693</del> (PR was closed because this one will suffice) > - #2707 This PR integrates the `ReviewModal` component in the core package for the Review and Ratings section. The actual review form implementation will be handled in a separate PR to be easy to review. - Adding schema configuration in sections.json for `ReviewModal` properties in the Headless CMS - Creating a new `ReviewModal` component in packages/core/src/components/reviews that will handle form logic - Integrating the modal within the ReviewsAndRatings UI with a temporary trigger button - Check `ReviewModal` structure in core package and its types declarations - Confirm that CMS-configured content is properly displayed <!--- Describe the steps with bullet points. Is there any external link that can be used to better test it or an example? ---> [Preview](https://starter-git-feat-add-review-modal-core-structure-vtex.vercel.app/) <!--- Add a link to a deploy preview from `starter.store` with this branch being used. ---> <!--- Tip: You can get an installable version of this branch from the CodeSandbox generated when this PR is created. ---> [FEATURE BRANCH](#2676) [Figma](https://www.figma.com/design/YXU6IX2htN2yg7udpCumZv/Reviews-%26-Ratings?node-id=128-22351&t=zALRZSwDWuF6UrjH-4) [SFS-2082](https://vtex-dev.atlassian.net/browse/SFS-2082) [SFS-2082]: https://vtex-dev.atlassian.net/browse/SFS-2082?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Fanny Chien <[email protected]> Co-authored-by: Bruno Guilera Gutchenzo <[email protected]> Co-authored-by: Fanny Chien <[email protected]>
>⚠️ THIS PR DEPENDS ON:⚠️ > - #2707 > - #2695 > - #2700 ## What's the purpose of this pull request? This PR implements the "Add Review" form functionality within the core package. > [!NOTE] > I also made some adjustments to global components (Rating, Textarea, CheckboxField, InputField). I've included them in this PR for efficiency, but can move them to separate PRs targeting main if preferred. ## How it works? - Review Modal Form: - Adjust AddReviewModal.tsx in the core package with form handling, validation, success states, and error management Integrated - Couldn't focus on checkbox field so I add a scrollIntoView for it -  - Add new cms configuration in `sections.json` - GraphQL Integration: - Added CreateProductReview mutation to handle the submission of review data - Defined appropriate types and integrated mutation documents in GraphQL schema - Developed a useAddReview hook that leverages useLazyQuery for handling review submission - Global Component Enhancements: - Rating: Added type="button" attribute so that it doesn't trigger submit inside form - CheckboxField: Implemented checkboxRef prop for better form control and adjusted label sizing - Textarea: Adjust label sizing - InputField: Fixed label positioning when error messages are present by updating positioning calculation -  ## How to test it? - Navigate to any product page and click on "Write a Review" - Test form validation by submitting without required fields - Verify rating selection works properly - Submit a complete review and confirm success state appears - Check error handling: - Not logged in - Duplicate review ### Starters Deploy Preview [Preview](https://starter-git-feat-add-review-modal-form-vtex.vercel.app/) <!--- Add a link to a deploy preview from `starter.store` with this branch being used. ---> <!--- Tip: You can get an installable version of this branch from the CodeSandbox generated when this PR is created. ---> ## References [FEATURE BRANCH](#2676) [Figma](https://www.figma.com/design/YXU6IX2htN2yg7udpCumZv/Reviews-%26-Ratings?node-id=128-22351&t=zALRZSwDWuF6UrjH-4) [SFS-2082](https://vtex-dev.atlassian.net/browse/SFS-2082) [SFS-2169](https://vtex-dev.atlassian.net/browse/SFS-2169)  [SFS-2082]: https://vtex-dev.atlassian.net/browse/SFS-2082?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
>⚠️ THIS PR DEPENDS ON:⚠️ > - #2707 ## What's the purpose of this pull request? This pull request introduces the reviews filtering and sorting feature to the `ReviewsAndRatings` section. ## How it works? New components for filtering and sorting reviews: * [`packages/core/src/components/reviews/FilterProductReviews/FilterProductReviews.tsx`](diffhunk://#diff-a2b0bd1e2cdbfbcf09123edfce232730783b1b1137ade37ee1e695fb03455afbR1-R55): Introduced `FilterProductReviews` component to filter reviews by rating. * [`packages/core/src/components/reviews/SortProductReviews/SortProductReviews.tsx`](diffhunk://#diff-c75acab76a9610dd3829f0261b68aff5951f22de317c4a8915c6794fe43d1fddR1-R52): Introduced `SortProductReviews` component to sort reviews by different criteria. Updates to `ReviewList` and `ReviewsAndRatings` sections: * [`packages/core/src/components/reviews/ReviewList/ReviewList.tsx`](diffhunk://#diff-28fec2fd4196ed19b480f08cff6c7b8bdd0f40429f986ced88b7b42616366385R1-R54): Added `ReviewList` component to display reviews with sorting and filtering options. * [`packages/core/src/components/sections/ReviewsAndRatings/ReviewsAndRatings.tsx`](diffhunk://#diff-053f669e6d7dbf149a46ce88aa4b6e46b857eb4791642ae6e1ffd5f110357ee4L3-R22): Updated `ReviewsAndRatings` section to include the new `ReviewList` component and handle its props. [[1]](diffhunk://#diff-053f669e6d7dbf149a46ce88aa4b6e46b857eb4791642ae6e1ffd5f110357ee4L3-R22) [[2]](diffhunk://#diff-3240d26fcff836d6cf071f404185609676c1bd28d2adaad248e94c88efae1e86L1-R25) [[3]](diffhunk://#diff-3240d26fcff836d6cf071f404185609676c1bd28d2adaad248e94c88efae1e86R35-R48) Styling updates: * [`packages/core/src/components/sections/ReviewsAndRatings/section.module.scss`](diffhunk://#diff-2a282117ceeb7a5db54e1b28de0fdd683cd8bd3821db36a6b02a8924f058af5bR3-R47): Updated styles to support the new review list and its header. ## How to test it? - Open a PDP and see if the selects are displayed correctly - Confirm that CMS-configured content is properly displayed <!--- Describe the steps with bullet points. Is there any external link that can be used to better test it or an example? ---> ### Starters Deploy Preview [Preview](https://starter-git-feat-filter-sort-select-cli-vtex.vercel.app/) <!--- Add a link to a deploy preview from `starter.store` with this branch being used. ---> <!--- Tip: You can get an installable version of this branch from the CodeSandbox generated when this PR is created. ---> ## References [FEATURE BRANCH](#2676) [Figma](https://www.figma.com/design/YXU6IX2htN2yg7udpCumZv/Reviews-%26-Ratings?node-id=130-32963&t=esjZ5E67A5FjirJa-4) [SFS-2171](https://vtex-dev.atlassian.net/browse/SFS-2171) [SFS-2171]: https://vtex-dev.atlassian.net/browse/SFS-2171?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Fanny Chien <[email protected]> Co-authored-by: Lucas Feijó <[email protected]>
What's the purpose of this pull request?
This pull request includes some changes to the
RatingSummarycomponent and its integration within theReviewsAndRatingssection, like adding a callback for the create review button, dynamically importing theRatingSummarycomponent, and updating theReviewsAndRatingssection to use the new properties and overrides.How it works?
Enhancements to
RatingSummarycomponent:onCreateReviewClickcallback property toRatingSummaryPropsto handle create review button clicks. [1] [2] [3]Integration of
RatingSummaryinReviewsAndRatingssection:RatingSummarycomponent inReviewsAndRatingsDefaultComponents.ReviewsAndRatingsSectionto pass new properties (ratingSummary,addReviewModal) toReviewsAndRatingscomponent.ReviewsAndRatingscomponent to accept and use new properties (ratingSummary,addReviewModal) and to use the overriddenRatingSummarycomponent. [1] [2]Type definitions update:
RatingSummaryPropsto overrides type definitions and updatedSectionsOverridesto includeRatingSummarycomponent. [1] [2]How to test it?