Feature #10556
openTo implement rate & review flow in EComm
Subtasks
Related issues
Updated by Ajit A 23 days ago
- Due date set to 08/27/2026
- Status changed from New to In Progress
- % Done changed from 0 to 80
- Estimated time changed from 8:00 h to 12:00 h
Module: Customer Reviews & Rating Management (Tab 5)
Frontend Changes (evergreen_pos_fe):
AdminReviewsTab.tsx (New Component):
Default Review Status: Set default status to "pending" for all newly submitted customer reviews.
Review Moderation Dropdown: Added inline status dropdown with full state transitions (Pending, Approved, Rejected, Hidden).
Debounced Search & Silent Fetch: Implemented 400ms search debouncing with silent background fetching to update table data smoothly without reloading skeleton UI.
Global Pagination Integration: Replaced standard pagination with ResponsivePaginationControls component to match the Orders tab design.
Table Columns & Copy Action:
Added S.No serial number column.
Formatted Order ID (e.g., OD463) with one-click copy-to-clipboard functionality.
Sorting & Filtering:
Added sortable column headers for Rating and Date & Time with single arrow indicators (↑ / ↓).
Added status and star rating filter controls.
URL Synchronization: Synced search, rating, and status filters with URL search parameters (?tab=5&search=...&status=...&rating=...).
catlogOrder.tsx:
Configured handleTabChange to automatically strip unneeded query parameters (subTab, catalog) from the URL when active on Tab 5.
AdminOrder.tsx:
Removed the obsolete Reviews subtab from the Orders page layout and resolved JSX element syntax formatting.
Backend Changes (evergreen_pos_be):
productReview.model.js:
Updated review schema default status from "approved" to "pending".
trust.service.js & trust.controller.js:
createProductReview: Created new reviews with default "pending" status.
listAllAdminReviews: Added dynamic server-side search, status filtering, star rating filtering, sorting (createdAt, rating), and pagination.
moderateReview: Updated status validation to allow moderation across all 4 statuses ("pending", "approved", "rejected", "hidden").
shop.route.js & ecom.route.js:
Registered endpoint PATCH /api/v1/nus-shop/all-reviews/:id/status for admin review status moderation.
order.service.js:
Refined order fulfillment status mapping for combined pickup and delivery orders.
Updated by Ajit A 22 days ago
Summary of Implementation:
Dynamic Environment Storefront Base URL Resolution:
Updated the EJS delivery email template link to dynamically resolve the storefront URL.
Automatically uses http://localhost:5174 in local development (isLocalRootDomain() === true) and the tenant's production domain (company.website) once deployed.
Updated email review button link format: <%= baseUrl >/evergreen/store/profile?tab=profile&subTab=orders&openReviewModal=true&productId=<= itemPid >&orderId=<= orderIdValue %>.
Email Link to My Orders Review Modal Flow:
Clicking "Rate & Review Product" from the delivery email navigates to the customer's My Orders page (profile?tab=profile&subTab=orders).
OrderList.tsx detects openReviewModal=true from URL parameters and automatically launches the Write a Review modal (ReviewModal) popup.
Guest / Email Link Review Submission Support:
Updated createProductReview in trust.service.js: When an unauthenticated user submits a review via an email link containing a valid orderId, the backend resolves customer details directly from the order and allows the review submission.
Product Review Form & UI Enhancements:
Photo Upload Integration: Added S3 photo upload capabilities (POST /v1/nus-shop/reviews/upload), image drop zone with camera icon, and thumbnail previews with delete functionality (up to 5 photos).
Rating Descriptors: Added rating label descriptors (Outstanding!, Good!, Average!, Fair!, Poor!) next to star selections.
Author Labeling: Updated review cards to display "You" with a "Y" avatar badge for the logged-in customer's own reviews.
Instant Post-Login Refresh: Added global auth event listeners (guestCartUpdated, userLogin) so the review form opens immediately after signing in without requiring a manual page reload.
Sign In Event Fix: Fixed event dispatch on the guest review callout to trigger openLoginModal.
Admin Approval Security & API Deduplication:
Admin Approval Filter: Enforced status = "approved" on public review queries (GET /api/v1/nus-shop/reviews/:productId), ensuring unapproved/pending reviews are hidden from public view until moderated.
Network Request Loop Fix: Implemented sessionStorage and reference guards (recordedViewsRef, loadedKeyRef, fetchedTrustPidRef) across productdetailsui.tsx and ProductReviewsPanel.tsx. Deduplicated recordProductView and fetchProductReviews API calls to execute exactly once per session.
Files Modified:
Backend (evergreen_pos_be)
src/services/nursery/order.service.js: Dynamic storeBaseUrl resolution & email template link format update.
src/controllers/nursery/trust.controller.js: Forwarded orderId to listProductReviews.
src/services/nursery/trust.service.js: Admin-approved reviews filtering, parameter destructuring fix (orderId), guest createProductReview support, and safe isMine string comparison.
Frontend (evergreenpos_E-commerce_new)
src/api/trustApi.ts: Forwarded orderId in fetchProductReviews and added uploadReviewPhoto.
src/features/products/components/ProductReviewsPanel.tsx: Added photo upload UI, rating descriptors, "You" label, openLoginModal fix, and instant auth update listener.
src/features/products/pages/productdetailsui.tsx: Deduplicated recordProductView and fetchProductReviews network requests.
src/features/profile/components/OrderList.tsx: Added URL search params handler for openReviewModal=true landing.
Updated by Ajit A 22 days ago
- % Done changed from 80 to 100
Customer Review Editing & Instant Updates:
Added a 3-dots action menu for logged-in users to edit their existing product reviews.
Enabled editing with pre-filled rating, title, body, and pre-uploaded S3 photo management.
Configured review updates to bypass re-moderation so edits publish immediately.
Modal Closing & URL Clean-up:
Automatically closes the ReviewModal upon successful submission or cancellation.
Clears openReviewModal=true, productId, and orderId parameters from the browser address bar (window.history.replaceState).
Admin Review Reply Feature:
Added a Reply / Edit Reply button and modal dialog in the Admin Dashboard (Reviews & Ratings tab).
Saved official store owner responses to MongoDB (adminReply, adminRepliedAt, adminRepliedBy).
Public Storeowner Response Display:
Displayed an official Response from Store Owner badge and callout box underneath customer review cards on the public product details page.
Admin Table Customer Contact Mapping:
Mapped customer Email and Phone Number in the same column in the Admin Reviews table.
Added individual 1-click Copy Buttons (FaRegCopy) for both Email and Phone Number.
Resolved customer contact info dynamically across Client and Order models (customerEmail, billingAddress, shippingAddress).
Removed the static string "Verified Customer".
Image Upload API Fix:
Added missing route POST /api/v1/nus-shop/reviews/upload for review photo S3 uploads.
🛠️ Repository File Changes
1. evergreen_pos_be (Backend)
src/models/nursery/productReview.model.js
: Added adminReply, adminRepliedAt, and adminRepliedBy fields to productReviewSchema.
src/controllers/nursery/trust.controller.js
: Passed adminReply parameter in moderateReview.
src/routes/nursery/shop.route.js
: Registered /reviews/upload endpoint for S3 review photo uploads.
src/services/nursery/trust.service.js
:
Updated moderateReview to save store owner responses.
Enhanced listAllAdminReviews to query Order and Client records for customer email and phone number.
Allowed review edits to maintain approved status without reverting to pending.
2. evergreen_pos_fe (Admin Dashboard FE)
src/pages/Nuresy/Inventory/Products/AdminReviewsTab.tsx
:
Added Reply action button and Store Response Modal dialog.
Rendered 💬 Store Reply: snippet in the review body cell.
Rendered customer Email and Phone Number with 1-click copy buttons in the Customer column.
3. evergreenpos_E-commerce_new (Customer Storefront FE)
src/features/products/components/ProductReviewsPanel.tsx
:
Added 3-dots action menu (Edit) for user's own reviews.
Added Response from Store Owner callout box under public reviews.
src/features/profile/components/ReviewModal.tsx
:
Added URL parameter clean-up logic on close or submit.
src/features/profile/components/OrderList.tsx
:
Handled modal closing & URL clean-up callback.
src/features/profile/components/OrderItemCard.tsx
:
Updated review button props and fixed status guard references.