Repository navigation
fix: landing page plp and sort fallback - #3297
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
WalkthroughRefactors the Sort component to accept optional label/options with DEFAULT_OPTIONS and dynamic option construction; updates LandingPage slug comparison and nests slug filters when querying content; changes CMS server types to use ChangesSort Component Optional Props with Defaults
LandingPage Slug Filter Structure
CMS Filters Type & Callsite Change
PreviewTag Styling Adjustment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
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. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/components/search/Sort/Sort.tsx`:
- Around line 29-37: The current optionsMap build uses Object.hasOwn to only
include keys present on the caller-supplied options, which hides non-overridden
sort options; change the reducer (or replace with a simple map) to iterate
unconditionally over SORT_OPTIONS_KEYS and for each key set acc[key] =
options[key] ?? DEFAULT_OPTIONS[key] so every sort key is present and caller
values simply override defaults; update the logic around optionsMap (referencing
optionsMap, SORT_OPTIONS_KEYS, options, and DEFAULT_OPTIONS) to remove the
Object.hasOwn guard and always merge with DEFAULT_OPTIONS.
In `@packages/core/src/components/templates/LandingPage/LandingPage.tsx`:
- Around line 147-151: The filters object passed into getSingleContent in
LandingPage.tsx is double-nested so the service (which expects
filters['settings.seo.slug'] directly) ignores the slug; update the call site to
pass a flat filters Record instead of { filters: { ... } }—i.e., when
contentContext.previewData?.contentType !== 'landingPage', supply filters with
'settings.seo.slug' at the top level (reference getSingleContent and the filters
argument and contentContext.previewData in LandingPage.tsx).
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: be565d84-39a7-42a8-a5b8-5ce38e11bfb8
📒 Files selected for processing (2)
packages/core/src/components/search/Sort/Sort.tsxpackages/core/src/components/templates/LandingPage/LandingPage.tsx
The getCMSPage function was spreading options.filters flat into the getCMSPagesByContentType call, causing the filters to be ignored and all landing pages to be returned unfiltered. This made any PLP slug incorrectly render as a landing page when contentSource.type is CMS.
f94eee5 to
a0d643c
Compare
@faststore/api
@faststore/cli
@faststore/components
@faststore/core
@faststore/diagnostics
@faststore/lighthouse
@faststore/sdk
@faststore/ui
commit: |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/core/src/components/search/Sort/Sort.tsx (1)
29-37:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPartial
optionsstill drops default sort entries.
Object.hasOwn(options, key)makes partial overrides behave like an allowlist, so non-overridden options disappear from the select. BuildoptionsMapunconditionally from all keys and use override-or-default per key.Proposed fix
const optionsMap = SORT_OPTIONS_KEYS.reduce( (acc, key) => { - if (Object.hasOwn(options, key)) { - acc[key] = options[key] ?? DEFAULT_OPTIONS[key] - } + acc[key] = options[key] ?? DEFAULT_OPTIONS[key] return acc }, {} as Record<SortOptionKeys, string> )As per coding guidelines, "Prefer flat conditionals over nested ifs: combine conditions with && or use early returns to avoid deep nesting and improve readability."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/components/search/Sort/Sort.tsx` around lines 29 - 37, The current optionsMap creation uses Object.hasOwn(options, key) which causes non-overridden keys to be omitted; change the reducer for SORT_OPTIONS_KEYS so it always assigns acc[key] = options[key] ?? DEFAULT_OPTIONS[key] for every key (remove the Object.hasOwn check) so partial options correctly fall back to DEFAULT_OPTIONS; update the reducer expression that builds optionsMap to unconditionally set each key using the override-or-default logic (symbols: optionsMap, SORT_OPTIONS_KEYS, options, DEFAULT_OPTIONS).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@packages/core/src/components/search/Sort/Sort.tsx`:
- Around line 29-37: The current optionsMap creation uses Object.hasOwn(options,
key) which causes non-overridden keys to be omitted; change the reducer for
SORT_OPTIONS_KEYS so it always assigns acc[key] = options[key] ??
DEFAULT_OPTIONS[key] for every key (remove the Object.hasOwn check) so partial
options correctly fall back to DEFAULT_OPTIONS; update the reducer expression
that builds optionsMap to unconditionally set each key using the
override-or-default logic (symbols: optionsMap, SORT_OPTIONS_KEYS, options,
DEFAULT_OPTIONS).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2b623080-9b79-4279-9eb3-f581808be477
📒 Files selected for processing (3)
packages/core/src/components/search/Sort/Sort.tsxpackages/core/src/components/templates/LandingPage/LandingPage.tsxpackages/core/src/server/cms/index.ts
## What's the purpose of this pull request? Tweaks button size. <img width="1916" height="654" alt="image" src="https://github.com/user-attachments/assets/d7146601-f5bc-4ca3-905a-997ee69ad6f9" /> <img width="1919" height="765" alt="image" src="https://github.com/user-attachments/assets/3df0f830-ac1c-4e85-a097-2c0e49d73fb3" />




What's the purpose of this pull request?
This pull request introduces improvements to the sorting component and fixes to landing page retrieval logic. The main changes include providing default sort options, making the sort label and options optional, and correcting how landing pages are matched and queried by slug.
Enhancements to sorting functionality:
DEFAULT_OPTIONSobject for sort options, making thelabelandoptionsprops of theSortcomponent optional and providing sensible defaults if they are not specified. (packages/core/src/components/search/Sort/Sort.tsx)packages/core/src/components/search/Sort/Sort.tsx)Bug fixes for landing page slug matching:
/to the input slug, ensuring accurate page retrieval. (packages/core/src/components/templates/LandingPage/LandingPage.tsx)filtersobject, aligning with expected API requirements. (packages/core/src/components/templates/LandingPage/LandingPage.tsx)Summary by CodeRabbit
Bug Fixes
Refactor
Chores
Style