Display product metafields as Properties on PDP - #76
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a new ProductMetafields component and integrates it into the product details page; the product fetch now requests metafields so the UI can render a “Properties” section with type-specific formatting. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/products/ProductMetafields.tsx`:
- Around line 11-26: Add explicit TypeScript return types: declare renderValue
to return React.ReactNode (or string | JSX.Element), declare normalizeType to
return string, and give ProductMetafields an explicit
React.FC<ProductMetafieldsProps> (or function component returning JSX.Element)
return type. Update signatures for renderValue(metafield: Metafield,
normalizedType: string): React.ReactNode, normalizeType(...): string, and
ProductMetafields({ metafields }: ProductMetafieldsProps): JSX.Element (or
React.FC<ProductMetafieldsProps>) so the component and helpers have strict,
explicit return contracts and avoid implicit any.
- Around line 19-20: The RichText branch in renderValue is injecting
metafield.value via dangerouslySetInnerHTML without sanitization and renderValue
lacks an explicit TypeScript return type; fix by adding HTML sanitization before
DOM injection (install and import a sanitizer like isomorphic-dompurify or call
a shared sanitizeHtml helper) and use the sanitized string in the <span
dangerouslySetInnerHTML={{ __html: sanitizedValue }} />; alternatively, if you
opt to rely on backend guarantees, add a clear comment and type-level assertion
to document that guarantee. Also add an explicit return type to renderValue
(e.g., React.ReactNode) and audit ProductDetails.tsx where product.description
is similarly injected to apply the same sanitization or documentation pattern.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1ad973e2-9da6-4f70-8275-a07aa591bca9
📒 Files selected for processing (3)
src/app/[country]/[locale]/(storefront)/products/[slug]/ProductDetails.tsxsrc/app/[country]/[locale]/(storefront)/products/[slug]/ProductDetailsWrapper.tsxsrc/components/products/ProductMetafields.tsx
Add a Properties section to the product detail page that renders metafields returned by the Spree API, styled consistently with the existing Details section. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…SetInnerHTML Add React.ReactNode return type to renderValue and React.JSX.Element | null to ProductMetafields. Document that dangerouslySetInnerHTML usage in both ProductMetafields and ProductDetails receives admin-authored HTML from the Spree CMS backend (trusted source). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e3b3bbd to
a553050
Compare
Changes
Added
ProductMetafieldscomponent to render product metafields as a "Properties" section on the product details page::delimiterUpdated
ProductDetailsWrapperto expand themetafieldsrelation when fetching product dataIntegrated metafields display into
ProductDetailscomponent, positioned before the "Details" sectionFeatures
Summary by CodeRabbit