Skip to content

feat: add review modal core structure - #2695

Merged
hellofanny merged 24 commits into
feat/reviews-and-ratingsfrom
feat/add-review-modal-core-structure
Mar 13, 2025
Merged

hellofanny merged 24 commits into
feat/reviews-and-ratingsfrom
feat/add-review-modal-core-structure

Conversation

@artursantiago

@artursantiago artursantiago commented Feb 19, 2025 •

Copy link
Copy Markdown
Contributor

⚠️ THIS PR DEPENDS ON: ⚠️

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

Starters Deploy Preview

Preview

References

FEATURE BRANCH
Figma
SFS-2082

@artursantiago artursantiago changed the title Feat/add review modal core structure feat: add review modal core structure Feb 19, 2025
@codesandbox-ci

codesandbox-ci Bot commented Feb 19, 2025 •

Copy link
Copy Markdown

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.

@Guilera
Guilera force-pushed the feat/reviews-and-ratings branch from cc15cdd to 33db057 Compare February 19, 2025 17:34
@artursantiago
artursantiago force-pushed the feat/add-review-modal-core-structure branch from 0bd85ce to ffa6c4b Compare February 20, 2025 16:10
@artursantiago
artursantiago force-pushed the feat/add-review-modal-core-structure branch from ffa6c4b to 6906fa9 Compare February 21, 2025 12:18
@artursantiago artursantiago self-assigned this Feb 21, 2025
@artursantiago
artursantiago marked this pull request as ready for review February 21, 2025 16:49
@artursantiago
artursantiago requested a review from a team as a code owner February 21, 2025 16:49
@artursantiago
artursantiago requested review from hellofanny, lariciamota and renatamottam and removed request for a team, lariciamota and renatamottam February 21, 2025 16:49
artursantiago and others added 7 commits March 10, 2025 09:20
## What's the purpose of this pull request?

To add the Rating Summary component

## How it works?

The component is responsible for:
- display the current average rating of the product
- display the number of reviews of the product
- display the rating distribution of the product
- to have a button to open the modal to write a review (current not
integrated, it's just emit an alert. It's depends on another task)

>[!IMPORTANT]
> If the product has no reviews, the component should display a message
saying that there are no reviews yet.
Both the text from the button and the text from number of reviews
changes when there isn't any review yet.

>[!IMPORTANT]
> Plural and singular cases for the text label of the rating counter
must be handled

> [!IMPORTANT]
> The component shouldn't be displayed if the product has no reviews and
the user is not on desktop

### Starters Deploy Preview

[PREVIEW](https://starter-git-feat-rating-summary-vtex.vercel.app/)

## References

[FEATURE BRANCH](#2676)
[JIRA SFS-2166](https://vtex-dev.atlassian.net/browse/SFS-2166)
[JIRA SFS-2167](https://vtex-dev.atlassian.net/browse/SFS-2167)
[JIRA SFS-2069](https://vtex-dev.atlassian.net/browse/SFS-2069)
@artursantiago
artursantiago force-pushed the feat/add-review-modal-core-structure branch from 71ecddc to c87654f Compare March 11, 2025 12:32
hellofanny added a commit that referenced this pull request Mar 11, 2025
## What's the purpose of this pull request?

This pull request includes some changes to the `RatingSummary` component
and its integration within the `ReviewsAndRatings` section, like adding
a callback for the create review button, dynamically importing the
`RatingSummary` component, and updating the `ReviewsAndRatings` section
to use the new properties and overrides.

## How it works?

Enhancements to `RatingSummary` component:

* Added `onCreateReviewClick` callback property to `RatingSummaryProps`
to handle create review button clicks.
[[1]](diffhunk://#diff-3842b6542c4617b9089bcfe95aae46869139ddb93e8dcd66334f2e63bea0f669R43-R46)
[[2]](diffhunk://#diff-3842b6542c4617b9089bcfe95aae46869139ddb93e8dcd66334f2e63bea0f669R96)
[[3]](diffhunk://#diff-3842b6542c4617b9089bcfe95aae46869139ddb93e8dcd66334f2e63bea0f669L110-R115)

Integration of `RatingSummary` in `ReviewsAndRatings` section:

* Dynamically imported `RatingSummary` component in
`ReviewsAndRatingsDefaultComponents`.
* Updated `ReviewsAndRatingsSection` to pass new properties
(`ratingSummary`, `addReviewModal`) to `ReviewsAndRatings` component.
* Modified `ReviewsAndRatings` component to accept and use new
properties (`ratingSummary`, `addReviewModal`) and to use the overridden
`RatingSummary` component.
[[1]](diffhunk://#diff-3240d26fcff836d6cf071f404185609676c1bd28d2adaad248e94c88efae1e86R4-R27)
[[2]](diffhunk://#diff-3240d26fcff836d6cf071f404185609676c1bd28d2adaad248e94c88efae1e86L21-R45)

Type definitions update:

* Added `RatingSummaryProps` to overrides type definitions and updated
`SectionsOverrides` to include `RatingSummary` component.
[[1]](diffhunk://#diff-493fb3077e5ff0ebee6d765533eda8dd478cbb7ef439d8fbc526fd9bed7daa7cR45)
[[2]](diffhunk://#diff-493fb3077e5ff0ebee6d765533eda8dd478cbb7ef439d8fbc526fd9bed7daa7cL363-R369)

## How to test it?

- You can check the starter build on the starter preview of the branch
bellow that is already using this changes:
> - #2695

---------

Co-authored-by: Fanny Chien <[email protected]>

@hellofanny hellofanny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well donee 🚀

I've left just a few suggestions, small details, lemme know what do you think :)

image

@lucasfp13 lucasfp13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed this CI error

Screenshot 2025-03-13 at 09 23 01

@artursantiago

Copy link
Copy Markdown
Contributor Author

Noticed this CI error

Screenshot 2025-03-13 at 09 23 01

There is a problem with the faststore pipe, but in the starter pipe you can see that the build worked correctly.

@hellofanny
hellofanny merged commit f6cf920 into feat/reviews-and-ratings Mar 13, 2025
@hellofanny
hellofanny deleted the feat/add-review-modal-core-structure branch March 13, 2025 17:58
artursantiago added a commit that referenced this pull request Mar 17, 2025
>⚠️ 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]>
artursantiago added a commit that referenced this pull request Mar 24, 2025
>⚠️ 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
-
![image](https://github.com/user-attachments/assets/2d711653-40c0-4668-92b3-ffae2192b6bb)

  - 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
-
![image](https://github.com/user-attachments/assets/fc20b766-14c0-430e-9e22-ebd63a42a892)


## 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)


![image](https://github.com/user-attachments/assets/bf0d9a2b-1f87-4c4f-857c-6cc897c8a989)


[SFS-2082]:
https://vtex-dev.atlassian.net/browse/SFS-2082?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants