Skip to content

fix: add expands for page template modules#870

Merged
smarcet merged 3 commits intomasterfrom
fix/page-template-expands
Apr 14, 2026
Merged

fix: add expands for page template modules#870
smarcet merged 3 commits intomasterfrom
fix/page-template-expands

Conversation

@tomrndom
Copy link
Copy Markdown

@tomrndom tomrndom commented Apr 14, 2026

ref: https://app.clickup.com/t/86b9c5ayz?nocache=1776062017712

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • New Features

    • Enhanced data retrieval for show pages and sponsor pages to include modules and sponsorship types.
    • Improved timezone-aware handling for upload deadline timestamps.
    • Refined document module file data processing for better file management.
  • Refactor

    • Optimized internal data transformation logic for page modules and sponsorship data.

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Show Pages API Parameter Updates
src/actions/show-pages-actions.js
Modified API expand parameters: getShowPages and getShowPage now request sponsorship_types and modules expansions; removed sponsorship_types from fields list.
Show Pages Reducer Updates
src/reducers/sponsors/show-pages-list-reducer.js
Changed sponsorship_types transformation in RECEIVE_SHOW_PAGE to map values to IDs (pageData.sponsorship_types.map((st) => st.id)) instead of spreading raw array.
Sponsor Pages Action Refactoring
src/actions/sponsor-pages-actions.js
Refactored getSponsorManagedPages and getSponsorCustomizedPages from curried to direct async function returns; updated expand parameters to include modules alongside allowed_add_ons.
Sponsor Pages Module Transformation
src/reducers/sponsors/sponsor-page-pages-list-reducer.js
Enhanced RECEIVE_SPONSOR_CUSTOMIZED_PAGE reducer to transform module data: converts epoch upload_deadline to timezone-aware format and normalizes document module files into structured array with file_path and public_url fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • romanetar
  • smarcet

Poem

🐰 Fields now flow with modules in sight,
Sponsor pages refactored right,
Timezones heed the reducer's call,
Sponsorships mapped by IDs, once all!
With files normalized, transformations bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: add expands for page template modules' directly and accurately summarizes the main change: adding expand parameters for modules across multiple page-related action and reducer files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/page-template-expands

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 | 🟡 Minor

Add a safe fallback before mapping sponsorship_types.

At Line 133, pageData.sponsorship_types.map(...) can throw if the API ever returns null/missing relation data. A defensive array check avoids a hard crash in RECEIVE_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

📥 Commits

Reviewing files that changed from the base of the PR and between b0c6bd0 and 1f47ec9.

📒 Files selected for processing (4)
  • src/actions/show-pages-actions.js
  • src/actions/sponsor-pages-actions.js
  • src/reducers/sponsors/show-pages-list-reducer.js
  • src/reducers/sponsors/sponsor-page-pages-list-reducer.js

@tomrndom tomrndom requested a review from smarcet April 14, 2026 14:36
Copy link
Copy Markdown

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

LGTM

@smarcet smarcet merged commit e4871d1 into master Apr 14, 2026
9 checks passed
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.

2 participants