Skip to content

fix: use denormalize function for modules for sponsor managed pages#940

Open
tomrndom wants to merge 1 commit into
masterfrom
fix/sponsor-managed-pages-modules-denormalize
Open

fix: use denormalize function for modules for sponsor managed pages#940
tomrndom wants to merge 1 commit into
masterfrom
fix/sponsor-managed-pages-modules-denormalize

Conversation

@tomrndom
Copy link
Copy Markdown

@tomrndom tomrndom commented May 15, 2026

ref: https://app.clickup.com/t/86b9x7fbm

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

Summary by CodeRabbit

  • Refactor
    • Consolidated internal page module processing logic to improve code maintainability and reduce dependencies.

Review Change Stack

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

Refactored sponsor page module transformation logic to delegate to shared utilities. Removed moment-timezone and epochToMomentTimeZone imports, replaced inline module mapping in actions and reducer with calls to normalizePageTemplateModules() and denormalizePageModules(), centralizing upload_deadline and document field handling.

Changes

Module Normalization Refactoring

Layer / File(s) Summary
Dependency imports and constants cleanup
src/actions/sponsor-pages-actions.js, src/reducers/sponsors/sponsor-page-pages-list-reducer.js
Removed moment-timezone and epochToMomentTimeZone imports; action module no longer imports PAGES_MODULE_KINDS while reducer now imports it alongside denormalizePageModules utility.
Action module module normalization delegation
src/actions/sponsor-pages-actions.js
Managed-page "to customize" normalization now calls normalizePageTemplateModules(entity.modules) instead of inline per-module transformation, centralizing media/document field reshaping and upload_deadline handling.
Reducer module denormalization delegation
src/reducers/sponsors/sponsor-page-pages-list-reducer.js
RECEIVE_SPONSOR_MANAGED_PAGE and RECEIVE_SPONSOR_CUSTOMIZED_PAGE handlers now call denormalizePageModules(...) with summit timezone, removing inline module mapping and upload_deadline/document field conversion logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • fntechgit/summit-admin#862: Updates sponsor/show page reducer to remove inline module denormalization and delegate to denormalizePageModules utility.
  • fntechgit/summit-admin#841: Introduced the sponsor managed-page "customize" flow with module normalization that this PR refactors into shared utilities.
  • fntechgit/summit-admin#805: Modified sponsor page module normalization logic in actions that this PR centralizes into shared utilities.

Suggested reviewers

  • romanetar
  • smarcet

Poem

🐰 The modules once scattered in actions and state,
Now gather in shared utilities, centralized and great!
No more timezone conversions scattered about,
One source of truth—refactoring with a joyful shout! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: refactoring to use a denormalize function for module processing in sponsor managed pages, which aligns with the actual changes in both files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/sponsor-managed-pages-modules-denormalize

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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/actions/sponsor-pages-actions.js (1)

205-206: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pass summitTZ through the managed-page module normalization path.

This save path now calls normalizePageTemplateModules(entity.modules) without the summit timezone, while the customized-page save path passes summitTZ and the reducer denormalizes module deadlines with that timezone. In non-UTC summits, managed-page edits can round-trip upload_deadline incorrectly.

Suggested fix
 export const saveSponsorManagedPage =
   (entity) => async (dispatch, getState) => {
     const { currentSummitState, currentSponsorState } = getState();
     const { currentSummit } = currentSummitState;
+    const summitTZ = currentSummit.time_zone.name;
     const {
       entity: { id: sponsorId }
     } = currentSponsorState;
     const accessToken = await getAccessTokenSafely();
@@
     if (entity.id) {
-      const normalizedEntity = normalizeSponsorManagedPageToCustomize(entity);
+      const normalizedEntity = normalizeSponsorManagedPageToCustomize(
+        entity,
+        summitTZ
+      );
@@
-const normalizeSponsorManagedPageToCustomize = (entity) => {
+const normalizeSponsorManagedPageToCustomize = (entity, summitTZ) => {
   const normalizedEntity = {
     ...entity,
     ...normalizeSelectAllField(
       entity.allowed_add_ons,
       "apply_to_all_add_ons",
       "allowed_add_ons"
     )
   };
 
-  normalizedEntity.modules = normalizePageTemplateModules(entity.modules);
+  normalizedEntity.modules = normalizePageTemplateModules(
+    entity.modules,
+    summitTZ
+  );

Also applies to: 300-310

🤖 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 `@src/actions/sponsor-pages-actions.js` around lines 205 - 206, The
managed-page save path is calling normalizeSponsorManagedPageToCustomize(entity)
which in turn calls normalizePageTemplateModules(entity.modules) without passing
summitTZ, causing module deadlines to be denormalized with the wrong timezone;
update normalizeSponsorManagedPageToCustomize (and any other managed-page
normalization call sites around the other occurrence at ~300-310) to accept and
forward summitTZ into normalizePageTemplateModules (i.e., call
normalizePageTemplateModules(entity.modules, summitTZ)) so the same summitTZ
used by the customized-page path is used for denormalizing upload_deadline.
🤖 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.

Outside diff comments:
In `@src/actions/sponsor-pages-actions.js`:
- Around line 205-206: The managed-page save path is calling
normalizeSponsorManagedPageToCustomize(entity) which in turn calls
normalizePageTemplateModules(entity.modules) without passing summitTZ, causing
module deadlines to be denormalized with the wrong timezone; update
normalizeSponsorManagedPageToCustomize (and any other managed-page normalization
call sites around the other occurrence at ~300-310) to accept and forward
summitTZ into normalizePageTemplateModules (i.e., call
normalizePageTemplateModules(entity.modules, summitTZ)) so the same summitTZ
used by the customized-page path is used for denormalizing upload_deadline.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d99d5b2-8404-4a1e-a24c-d39e3ed3ca79

📥 Commits

Reviewing files that changed from the base of the PR and between 81351ea and 5aa44f9.

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

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.

1 participant