Skip to content

fix: page template popup#812

Merged
smarcet merged 3 commits intomasterfrom
fix/edit-sponsor-page-template
Mar 5, 2026
Merged

fix: page template popup#812
smarcet merged 3 commits intomasterfrom
fix/edit-sponsor-page-template

Conversation

@santipalenque
Copy link

@santipalenque santipalenque commented Mar 4, 2026

https://app.clickup.com/t/86b79917k

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced validation for media module properties to ensure upload deadlines and file types are handled correctly.
  • Refactor

    • Improved page template dialog state management for better form handling and user interaction flows.
    • Simplified component architecture for page template creation and editing.

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6bb72a73-9f12-4e8b-97a6-841785aaf9d1

📥 Commits

Reviewing files that changed from the base of the PR and between e0ede60 and 4291935.

📒 Files selected for processing (1)
  • src/reducers/sponsors/show-pages-list-reducer.js

📝 Walkthrough

Walkthrough

This PR refactors page template and show-page handling by removing timezone (summitTZ) parameter passing across components and actions. The timezone transformation is relocated to the show-pages reducer. API expansion parameters are reduced, form control is changed from ID-based to dialog-state management, and stricter guards are added for MEDIA module normalization.

Changes

Cohort / File(s) Summary
Action and Reducer Updates
src/actions/page-template-actions.js, src/actions/show-pages-actions.js, src/reducers/sponsors/show-pages-list-reducer.js
Removed getState from getPageTemplates thunk; reduced API expansion from "modules,modules.file_type" to "modules"; added guards for MEDIA module properties (upload_deadline, file_type_id); moved timezone transformation logic to show-pages reducer with epochToMomentTimeZone utility.
Page Template Components
src/pages/sponsors-global/page-templates/page-template-list-page.js, src/pages/sponsors-global/page-templates/page-template-popup/index.js
Refactored PageTemplateListPage from ID-based to dialog-state control; added openPageDialog state and resetPageTemplateForm integration; removed Redux connection from PageTemplatePopup, simplified props by removing summitTZ and resetPageTemplateForm; removed timezone normalization from component initialization.
Show Pages Component
src/pages/sponsors/show-pages-list-page/index.js
Removed summitTZ prop from ShowPagesListPage and its usage in PageTemplatePopup invocation; added handleNewShowPage handler to reset show-page form before opening dialog.
Reducer State
src/reducers/sponsors_inventory/page-template-list-reducer.js
Removed summitTZ property from DEFAULT_STATE object.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #770: Inverse changes—adds summitTZ and related timezone normalization to page templates and show-page components, while this PR removes these elements throughout the codebase.
  • PR #755: Implements the same MEDIA module normalization guards (upload_deadline, file_type_id) and PAGE_MODULES_MEDIA_TYPES handling in page-template-actions.
  • PR #764: Modifies the same getPageTemplates thunk signature to remove getState parameter dependency.

Suggested reviewers

  • romanetar
  • smarcet

Poem

🐰 Timezones fade like morning dew,
Dialog states shine fresh and new,
Redux chains we gently sever,
Props grow light, components cleaner ever!
Simpler paths, the rabbit's way—
Refactored code hops brighter today! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: page template popup' is vague and generic, using minimal descriptive language that does not clearly convey the specific changes made across multiple files and modules. Consider a more specific title that describes the main technical change, such as 'fix: remove summitTZ dependency and simplify page template popup' or 'fix: refactor page template state management and file handling'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/edit-sponsor-page-template

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

Copy link

@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.

Actionable comments posted: 3

🤖 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/mui/formik-inputs/mui-formik-file-size-field.js`:
- Around line 12-16: The local state val initialized from field.value can get
out of sync when the Formik field changes externally; update the component to
watch field.value and reset val accordingly by adding a useEffect that
recalculates initialValue = field.value != null ? (field.value /
BYTES_PER_MB).toFixed(DECIMAL_DIGITS) : 0 and calls setVal(initialValue)
whenever field.value changes so the displayed value stays in sync with the
Formik field (leave the existing useState(initialValue) and preserve
DECIMAL_DIGITS, BYTES_PER_MB, field, val, setVal identifiers).

In `@src/pages/sponsors-global/page-templates/page-template-popup/index.js`:
- Around line 232-236: The PageTemplatePopup component is missing a PropTypes
entry for the pageTemplate prop used to set initialValues; update
PageTemplatePopup.propTypes to include pageTemplate with the appropriate shape
(e.g., PropTypes.object or a PropTypes.shape describing fields used by
initialValues) and mark it as required if it must always be provided,
referencing PageTemplatePopup, pageTemplate, and initialValues so the component
prop validation matches actual usage.

In `@src/reducers/sponsors/show-pages-list-reducer.js`:
- Around line 119-137: In the RECEIVE_SHOW_PAGE handler, epochToMomentTimeZone
is being called with state.summitTZ which can be null; update the modules
mapping inside currentShowPage so you only call epochToMomentTimeZone when
state.summitTZ is truthy (or use optional chaining to guard the call and/or
chain .format()), e.g. check state.summitTZ before converting each
m.upload_deadline and otherwise leave the raw value (or set null) to avoid
passing null timezone to epochToMomentTimeZone; modify the mapping around
epochToMomentTimeZone in the currentShowPage construction to add this guard.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cdd7affd-41f2-450b-976d-69a341e23c5e

📥 Commits

Reviewing files that changed from the base of the PR and between 4798a75 and e0ede60.

📒 Files selected for processing (8)
  • src/actions/page-template-actions.js
  • src/actions/show-pages-actions.js
  • src/components/mui/formik-inputs/mui-formik-file-size-field.js
  • src/pages/sponsors-global/page-templates/page-template-list-page.js
  • src/pages/sponsors-global/page-templates/page-template-popup/index.js
  • src/pages/sponsors/show-pages-list-page/index.js
  • src/reducers/sponsors/show-pages-list-reducer.js
  • src/reducers/sponsors_inventory/page-template-list-reducer.js

Comment on lines 232 to 236
PageTemplatePopup.propTypes = {
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
onSave: PropTypes.func.isRequired,
summitTZ: PropTypes.string.isRequired
onSave: PropTypes.func.isRequired
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing pageTemplate prop type definition.

The pageTemplate prop is used at line 130 for initialValues but is not defined in PropTypes.

Proposed fix
 PageTemplatePopup.propTypes = {
+  pageTemplate: PropTypes.object.isRequired,
   open: PropTypes.bool.isRequired,
   onClose: PropTypes.func.isRequired,
   onSave: PropTypes.func.isRequired
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
PageTemplatePopup.propTypes = {
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
onSave: PropTypes.func.isRequired,
summitTZ: PropTypes.string.isRequired
onSave: PropTypes.func.isRequired
};
PageTemplatePopup.propTypes = {
pageTemplate: PropTypes.object.isRequired,
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
onSave: PropTypes.func.isRequired
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors-global/page-templates/page-template-popup/index.js` around
lines 232 - 236, The PageTemplatePopup component is missing a PropTypes entry
for the pageTemplate prop used to set initialValues; update
PageTemplatePopup.propTypes to include pageTemplate with the appropriate shape
(e.g., PropTypes.object or a PropTypes.shape describing fields used by
initialValues) and mark it as required if it must always be provided,
referencing PageTemplatePopup, pageTemplate, and initialValues so the component
prop validation matches actual usage.

@fntechgit fntechgit deleted a comment from coderabbitai bot Mar 5, 2026
Copy link

@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 827fd4a into master Mar 5, 2026
8 of 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