fix: add expands for page template modules#870
Conversation
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
📝 WalkthroughWalkthroughThe PR updates API request parameters across show-pages and sponsor-pages actions, adding module and sponsorship-type expansions. Function implementations in sponsor-pages actions are refactored from curried to direct async functions. Reducer logic is enhanced to transform sponsorship_types to IDs and normalize modules with timezone conversions and file mappings. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/reducers/sponsors/show-pages-list-reducer.js (1)
131-151:⚠️ Potential issue | 🟡 MinorAdd a safe fallback before mapping
sponsorship_types.At Line 133,
pageData.sponsorship_types.map(...)can throw if the API ever returnsnull/missing relation data. A defensive array check avoids a hard crash inRECEIVE_SHOW_PAGE.💡 Suggested hardening
- const sponsorshipTypeIds = pageData.apply_to_all_types - ? ["all"] - : pageData.sponsorship_types.map((st) => st.id); + const sponsorshipTypeIds = pageData.apply_to_all_types + ? ["all"] + : Array.isArray(pageData.sponsorship_types) + ? pageData.sponsorship_types.map((st) => st.id) + : [];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/reducers/sponsors/show-pages-list-reducer.js` around lines 131 - 151, The mapping of pageData.sponsorship_types in the RECEIVE_SHOW_PAGE handling can throw if sponsorship_types is null/undefined; update the construction of sponsorshipTypeIds to defensively handle missing data (e.g., use Array.isArray(pageData.sponsorship_types) ? pageData.sponsorship_types.map(st => st.id) : [] or (pageData.sponsorship_types || []).map(...)) so currentShowPage.sponsorship_types is always an array; adjust the logic around pageData.apply_to_all_types accordingly in the same block where currentShowPage is created.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/reducers/sponsors/show-pages-list-reducer.js`:
- Around line 131-151: The mapping of pageData.sponsorship_types in the
RECEIVE_SHOW_PAGE handling can throw if sponsorship_types is null/undefined;
update the construction of sponsorshipTypeIds to defensively handle missing data
(e.g., use Array.isArray(pageData.sponsorship_types) ?
pageData.sponsorship_types.map(st => st.id) : [] or (pageData.sponsorship_types
|| []).map(...)) so currentShowPage.sponsorship_types is always an array; adjust
the logic around pageData.apply_to_all_types accordingly in the same block where
currentShowPage is created.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5b530740-a75f-4e96-9efa-ef6f803c4d55
📒 Files selected for processing (4)
src/actions/show-pages-actions.jssrc/actions/sponsor-pages-actions.jssrc/reducers/sponsors/show-pages-list-reducer.jssrc/reducers/sponsors/sponsor-page-pages-list-reducer.js
ref: https://app.clickup.com/t/86b9c5ayz?nocache=1776062017712
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com
Summary by CodeRabbit
New Features
Refactor