Skip to content

fix: refactor sponsor page routes#859

Merged
smarcet merged 3 commits intomasterfrom
fix/sponsor-section-routes
Apr 7, 2026
Merged

fix: refactor sponsor page routes#859
smarcet merged 3 commits intomasterfrom
fix/sponsor-section-routes

Conversation

@santipalenque
Copy link
Copy Markdown

@santipalenque santipalenque commented Apr 6, 2026

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

Summary by CodeRabbit

  • New Features

    • New unified Sponsor detail page with a tabbed navigation bar for sponsor management.
  • Refactor

    • Replaced legacy edit page and hash-fragment tabs with path-based tabs; consolidated forms and general sponsor UI into the new page.
    • Moved general sponsor form into the sponsor page tab structure.
  • Chores

    • Applied access-control gating to several sponsor admin tabs.
  • Tests

    • Updated tests to follow the new page and path-based navigation.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

Replaces the legacy EditSponsorPage and legacy SponsorGeneralForm with a new SponsorPage router, TabNav, and tabDefs; moves SponsorGeneralForm under sponsor-page/tabs; adjusts routing in sponsor-id-layout; rewires many imports, Redux mappings, and access restrictions across sponsor-related tabs and tests.

Changes

Cohort / File(s) Summary
Removed legacy pages
src/pages/sponsors/edit-sponsor-page.js, src/components/forms/sponsor-general-form/index.js
Deleted old EditSponsorPage and legacy SponsorGeneralForm exports and related helpers.
New page & navigation
src/pages/sponsors/sponsor-page/index.js, src/pages/sponsors/sponsor-page/components/tab-nav.js, src/pages/sponsors/sponsor-page/tabDefs.js
Added SponsorPage router, TabNav for URL-based tab navigation, and tabDefs describing sponsor tabs (with nested Forms route).
Relocated general form & subcomponents
src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/index.js, .../sponsor-general-form/*
Added connected SponsorGeneralForm under sponsor-page/tabs and rewired its subcomponents; dispatch handlers call sponsor-related actions.
Routing/layout update
src/layouts/sponsor-id-layout.js
Simplified to render SponsorPage for all paths under match.url, removing nested Switch/Route special-casing.
Tab refactors & access control
src/pages/sponsors/sponsor-page/tabs/..., src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/..., src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/index.js, src/pages/sponsors/sponsor-page/tabs/manage-items/...
Many tabs now use currentSummit/currentSponsorState.entity, several connected components wrapped with Restrict(..., ACCESS_ROUTES.*), and some exports changed to connected/Restricted variants.
Import path rebases
many files under src/pages/sponsors/sponsor-page/tabs/...
Widespread relative import path adjustments (deeper traversal); mostly no logic changes.
Cart & forms prop/route changes
.../sponsor-cart-tab/index.js, .../sponsor-forms-tab/index.js, related components/tests
SponsorCartTab and forms tab props changed to use currentSummit (id); route segments and hash usage replaced by pathname-based routing; tests updated accordingly.
Tests & mocks updated
src/pages/sponsors/__tests__/edit-sponsor-page.test.js, various __tests__ under sponsor-page tabs
Tests and Jest mocks updated to new paths/components and to assert pathname-based navigation instead of hash fragments.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Browser
  participant TabNav
  participant SponsorPage
  participant Store as Redux
  participant API

  User->>Browser: click sponsor tab
  Browser->>TabNav: tab click event
  TabNav->>Browser: history.push(/app/summits/:sid/sponsors/:id/<tab>)
  Browser->>SponsorPage: route change → mount tab route
  SponsorPage->>Redux: dispatch fetch actions (ads, tiers, forms, purchases, badge scans...)
  Redux->>API: HTTP requests
  API-->>Redux: responses
  Redux-->>SponsorPage: updated props (entity, lists)
  SponsorPage-->>Browser: render selected tab component
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • romanetar
  • smarcet

"I hop across the code with cheerful paws,
Tabs rearranged and routes without old laws.
Old forms tucked in, new Nav takes the lead,
Redux fetches hum — a rabbit's happy deed.
🐇✨"

🚥 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: refactor sponsor page routes' directly describes the primary refactoring: consolidating sponsor page navigation from fragment-based (#forms, #users) to path-based routing and reorganizing the page structure.
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/sponsor-section-routes

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.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/index.js (1)

324-328: ⚠️ Potential issue | 🟡 Minor

Guard ItemSettingsModal render to satisfy required prop contract.

The item prop is declared as PropTypes.object.isRequired in ItemSettingsModal, but the current code passes null when settingsItem is null, violating the contract. Render the modal only when settingsItem exists.

Minimal fix
-        <ItemSettingsModal
-          item={settingsItem}
-          open={!!settingsItem}
-          onClose={() => setSettingsItem(null)}
-        />
+        {settingsItem && (
+          <ItemSettingsModal
+            item={settingsItem}
+            open
+            onClose={() => setSettingsItem(null)}
+          />
+        )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/index.js`
around lines 324 - 328, The ItemSettingsModal is being rendered with
item={settingsItem} even when settingsItem is null which violates its
PropTypes.object.isRequired; change the render so ItemSettingsModal is only
mounted when settingsItem is truthy (e.g. wrap the component in a conditional
that checks settingsItem) and keep the existing props (open, onClose using
setSettingsItem(null)) so onClose still clears state but the modal is never
instantiated with a null item.
src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js (1)

44-56: ⚠️ Potential issue | 🔴 Critical

Fix inconsistent jest.requireActual path causing pipeline failure.

The jest.mock path on line 44 correctly uses ../../../../../../actions/sponsor-pages-actions (6 directory levels up), but the jest.requireActual call on line 45 still uses the old path ../../../../actions/sponsor-pages-actions (4 levels up). This path inconsistency causes the Jest test suite failure shown in the pipeline logs.

🐛 Proposed fix
 jest.mock("../../../../../../actions/sponsor-pages-actions", () => ({
-  ...jest.requireActual("../../../../actions/sponsor-pages-actions"),
+  ...jest.requireActual("../../../../../../actions/sponsor-pages-actions"),
   getSponsorManagedPages: jest.fn(() => ({ type: "MOCK_ACTION" })),
   getSponsorCustomizedPages: jest.fn(() => ({ type: "MOCK_ACTION" })),
   getSponsorCustomizedPage: jest.fn(
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js`
around lines 44 - 56, The jest mock uses a 6-level path but the nested
jest.requireActual call uses a 4-level path, causing resolution failures; update
the jest.requireActual call inside the jest.mock block so it imports the same
module path as the outer jest.mock (i.e., use the identical
"../../../../../../actions/sponsor-pages-actions" path) ensuring the mocked
exports like getSponsorManagedPages, getSponsorCustomizedPages,
getSponsorCustomizedPage, saveSponsorCustomizedPage, saveSponsorManagedPage,
resetSponsorPage, archiveCustomizedPage, and unarchiveCustomizedPage reference
the real module correctly.
🧹 Nitpick comments (3)
src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-form-item-from-inventory.js (1)

23-32: Consider replacing deep relative imports with aliases to reduce fragility.

Using path aliases (e.g., src/... or @/...) would make future sponsor-page moves safer and reduce churn like this across files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-form-item-from-inventory.js`
around lines 23 - 32, The imports in sponsor-form-item-from-inventory.js use
fragile deep relative paths (e.g., "../../../../../../../utils/rate-helpers") —
replace them with your project path aliases (e.g., "@/utils/rate-helpers" or
"src/utils/rate-helpers") for all referenced symbols (formatRateFromCents,
SearchInput, DEFAULT_CURRENT_PAGE, DEFAULT_PER_PAGE, getInventoryItems,
MuiTable, MenuButton) so the file can move without breaking imports; update the
import statements to use the configured alias and, if not already configured,
add the alias to your build/tsconfig/jsconfig and eslint resolver so the new
paths resolve correctly.
src/pages/sponsors/sponsor-page/index.js (1)

76-81: Remove unused props passed to TabNav.

TabNav derives currentSummit and sponsor from Redux state via its own mapStateToProps. The summitId and sponsorId props passed here are not used by the component.

♻️ Proposed fix
         <Box sx={{ borderBottom: 1, borderColor: "divider", mt: 2 }}>
           <TabNav
             history={history}
             location={location}
-            summitId={currentSummit.id}
-            sponsorId={entity.id}
           />
         </Box>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/sponsor-page/index.js` around lines 76 - 81, The TabNav
component is receiving unused props summitId and sponsorId (they are derived
from Redux in TabNav's mapStateToProps); remove the summitId={currentSummit.id}
and sponsorId={entity.id} props from the TabNav JSX here while keeping the
necessary history and location props so TabNav continues to receive routing
props only.
src/pages/sponsors/sponsor-page/components/tab-nav.js (1)

54-54: Consider handling when selectedTab doesn't match any visible tab.

If a user navigates directly to a URL for a tab they don't have access to (e.g., /app/summits/1/sponsors/42/users as a non-admin), selectedTab will be "users" but that tab won't be in the filtered list. MUI Tabs with value prop set to a non-existent tab value can behave unexpectedly (no tab selected, or console warning).

♻️ Suggested improvement
+ const visibleTabs = tabs.filter((t) => memberObj.hasAccess(t.accessRoute));
+ const selectedTab =
+   visibleTabs.find((t) => t.value === location.pathname.split("/")[6])?.value ||
+   visibleTabs[0]?.value;
- const selectedTab = location.pathname.split("/")[6] || tabs[0].value;

  // ...

  return (
    <Tabs
      value={selectedTab}
      onChange={(ev, val) => handleTabChange(val)}
      sx={{ minHeight: "36px" }}
    >
-     {tabs
-       .filter((t) => memberObj.hasAccess(t.accessRoute))
-       .map((tab) => (
+     {visibleTabs.map((tab) => (

Also applies to: 62-87

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/sponsor-page/components/tab-nav.js` at line 54, The
current computation of selectedTab using location.pathname.split("/")[6] can
yield a value that doesn't exist in the filtered/visible tabs list, causing MUI
Tabs to misbehave; update the logic that determines selectedTab (the variable
named selectedTab in this module/component) to check whether the derived value
exists in the current tabs array (after any filtering) and if not, fall back to
the first visible tab's value (e.g., tabs[0].value or the first element of the
filtered list) before passing it to the Tabs value prop so the component always
receives a valid tab value.
🤖 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/layouts/sponsor-id-layout.js`:
- Line 144: The catch-all Route (Route path={match.url} component={SponsorPage})
lets legacy /sponsor-forms/:form_id/items requests reach SponsorPage but they no
longer match internal /forms/:form_id/items routes; add a Redirect before that
catch-all that rewrites legacy /sponsor-forms/:form_id/* to /forms/:form_id/* to
preserve deep links; place this Redirect immediately above the Route that
renders SponsorPage so it runs first and references the same match.url base and
SponsorPage routing behavior.

In `@src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/index.js`:
- Around line 41-62: The component SponsorGeneralForm is calling getSponsorTiers
in handleSponsorshipPaginate but getSponsorTiers was not destructured from the
component props; update the SponsorGeneralForm parameter destructuring to
include getSponsorTiers so handleSponsorshipPaginate can call it, i.e., add
getSponsorTiers to the list of props (alongside sponsor, member, currentSummit,
etc.) and ensure any usages like handleSponsorshipPaginate(sponsor.id, ...)
reference the newly-destructured getSponsorTiers.

In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js`:
- Around line 58-61: The jest.mock call for sponsor-forms-actions uses an
inconsistent requireActual path; update the jest.requireActual argument to match
the mock module path ("../../../../../../actions/sponsor-forms-actions") so the
real module is correctly referenced, and keep the getSponsorships mock
(jest.fn(() => () => Promise.resolve())) as is; verify the change in the
jest.mock block that defines getSponsorships to ensure imports resolve
correctly.

In `@src/pages/sponsors/sponsor-users-list-per-sponsor/index.js`:
- Around line 163-166: The component now receives sponsor from mapStateToProps
(currentSponsorState.entity) which may have company: null and causes the
dereference sponsor.company.id to crash; update either mapStateToProps to ensure
sponsor has a safe default shape (e.g., merge entity with company: {} when
undefined) or change all dereferences to use a safe check (e.g., guard with
sponsor && sponsor.company && sponsor.company.id or optional chaining
sponsor.company?.id) so accesses in the component no longer throw when
currentSponsorState.entity.company is null; locate mapStateToProps, the sponsor
variable, and the places using sponsor.company.id and apply one of these fixes
consistently.

---

Outside diff comments:
In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/index.js`:
- Around line 324-328: The ItemSettingsModal is being rendered with
item={settingsItem} even when settingsItem is null which violates its
PropTypes.object.isRequired; change the render so ItemSettingsModal is only
mounted when settingsItem is truthy (e.g. wrap the component in a conditional
that checks settingsItem) and keep the existing props (open, onClose using
setSettingsItem(null)) so onClose still clears state but the modal is never
instantiated with a null item.

In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js`:
- Around line 44-56: The jest mock uses a 6-level path but the nested
jest.requireActual call uses a 4-level path, causing resolution failures; update
the jest.requireActual call inside the jest.mock block so it imports the same
module path as the outer jest.mock (i.e., use the identical
"../../../../../../actions/sponsor-pages-actions" path) ensuring the mocked
exports like getSponsorManagedPages, getSponsorCustomizedPages,
getSponsorCustomizedPage, saveSponsorCustomizedPage, saveSponsorManagedPage,
resetSponsorPage, archiveCustomizedPage, and unarchiveCustomizedPage reference
the real module correctly.

---

Nitpick comments:
In `@src/pages/sponsors/sponsor-page/components/tab-nav.js`:
- Line 54: The current computation of selectedTab using
location.pathname.split("/")[6] can yield a value that doesn't exist in the
filtered/visible tabs list, causing MUI Tabs to misbehave; update the logic that
determines selectedTab (the variable named selectedTab in this module/component)
to check whether the derived value exists in the current tabs array (after any
filtering) and if not, fall back to the first visible tab's value (e.g.,
tabs[0].value or the first element of the filtered list) before passing it to
the Tabs value prop so the component always receives a valid tab value.

In `@src/pages/sponsors/sponsor-page/index.js`:
- Around line 76-81: The TabNav component is receiving unused props summitId and
sponsorId (they are derived from Redux in TabNav's mapStateToProps); remove the
summitId={currentSummit.id} and sponsorId={entity.id} props from the TabNav JSX
here while keeping the necessary history and location props so TabNav continues
to receive routing props only.

In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-form-item-from-inventory.js`:
- Around line 23-32: The imports in sponsor-form-item-from-inventory.js use
fragile deep relative paths (e.g., "../../../../../../../utils/rate-helpers") —
replace them with your project path aliases (e.g., "@/utils/rate-helpers" or
"src/utils/rate-helpers") for all referenced symbols (formatRateFromCents,
SearchInput, DEFAULT_CURRENT_PAGE, DEFAULT_PER_PAGE, getInventoryItems,
MuiTable, MenuButton) so the file can move without breaking imports; update the
import statements to use the configured alias and, if not already configured,
add the alias to your build/tsconfig/jsconfig and eslint resolver so the new
paths resolve correctly.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97924e19-a7ad-4759-be77-ec64b83f563a

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa7555 and 674196c.

📒 Files selected for processing (37)
  • src/components/forms/sponsor-general-form/index.js
  • src/layouts/sponsor-id-layout.js
  • src/pages/sponsors/edit-sponsor-page.js
  • src/pages/sponsors/sponsor-page/components/tab-nav.js
  • src/pages/sponsors/sponsor-page/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-badge-scans/edit-badge-scan-popup.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-badge-scans/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/cart-note/__tests__/cart-note.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/cart-note/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/cart-view.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/__tests__/edit-cart-form.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/edit-cart-form.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/new-cart-form.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/select-form-dialog/__tests__/select-form-dialog.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/select-form-dialog/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/add-sponsor-form-template-popup/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/customized-form/customized-form-popup.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/customized-form/customized-form.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-form-item-from-inventory.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/add-extra-question-popup.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/add-tier-popup.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/badge-scan-settings.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/extra-questions.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/manage-tier-addons-popup.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/sponsor-header.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/sponsorship.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-media-upload-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/components/add-sponsor-page-template-popup/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js
  • src/pages/sponsors/sponsor-users-list-per-sponsor/index.js
💤 Files with no reviewable changes (2)
  • src/components/forms/sponsor-general-form/index.js
  • src/pages/sponsors/edit-sponsor-page.js

)}
/>
</Switch>
<Route path={match.url} component={SponsorPage} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether legacy route strings are still referenced (docs, links, navigation code).
rg -n --iglob '*.{js,jsx,ts,tsx,md}' 'sponsor-forms/.*/items|/sponsor-forms/'

Repository: fntechgit/summit-admin

Length of output: 2522


🏁 Script executed:

# First, let's examine the sponsor-id-layout.js file to understand the routing structure
wc -l src/layouts/sponsor-id-layout.js

Repository: fntechgit/summit-admin

Length of output: 102


🏁 Script executed:

# Read the sponsor-id-layout.js file to see the routing context
cat -n src/layouts/sponsor-id-layout.js

Repository: fntechgit/summit-admin

Length of output: 6364


🏁 Script executed:

# Check if there are any historical references to the old sponsor-forms route in git
git log --oneline --all --grep="sponsor-forms" | head -20

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

# Search for any route definitions or removals related to sponsor-forms in the layout file
rg -n "sponsor-forms|SponsorPage" src/layouts/sponsor-id-layout.js

Repository: fntechgit/summit-admin

Length of output: 813


🏁 Script executed:

# Check the test file context to understand those old route references
sed -n '120,175p' src/pages/sponsors/__tests__/edit-sponsor-page.test.js

Repository: fntechgit/summit-admin

Length of output: 1637


🏁 Script executed:

# Search for any navigation or link generation code that might reference sponsor-forms routes
rg -n "sponsor-forms|/items" --type js -B 2 -A 2 src/pages/sponsors/ | head -80

Repository: fntechgit/summit-admin

Length of output: 8994


🏁 Script executed:

# Check if SponsorPage component has any special handling for sponsor-forms paths
head -100 src/pages/sponsors/sponsor-page.js

Repository: fntechgit/summit-admin

Length of output: 159


🏁 Script executed:

# Find SponsorPage component
find src/pages/sponsors -name "*sponsor-page*" -type f

Repository: fntechgit/summit-admin

Length of output: 369


🏁 Script executed:

# Check if SponsorPage is a directory with index
ls -la src/pages/sponsors/sponsor-page/

Repository: fntechgit/summit-admin

Length of output: 353


🏁 Script executed:

# Look for any route configuration related to forms that might show the old pattern
rg -n "forms.*items|sponsor-forms" src/layouts/ src/routes/ 2>/dev/null || true

Repository: fntechgit/summit-admin

Length of output: 176


🏁 Script executed:

# Check if there's a forms route handler or if forms are nested under sponsor-page
rg -n "Route.*forms" src/pages/sponsors/sponsor-page/ -A 2

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

# Check sponsor-layout.js to see how forms are routed
cat -n src/layouts/sponsor-layout.js

Repository: fntechgit/summit-admin

Length of output: 5567


🏁 Script executed:

# Look for any route that might handle the legacy sponsor-forms pattern
rg -n "sponsor-forms|/forms/" src/layouts/sponsor-layout.js

Repository: fntechgit/summit-admin

Length of output: 146


🏁 Script executed:

# Check git history to see if sponsor-forms routes were explicitly removed
git log --oneline --all | grep -i "sponsor-form\|route" | head -20

Repository: fntechgit/summit-admin

Length of output: 430


🏁 Script executed:

# Search for any comments or TODOs about route changes
rg -n "TODO|FIXME|deprecated|legacy|backward" src/layouts/sponsor-id-layout.js src/layouts/sponsor-layout.js

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

# Final check: are there any references to SponsorPage handling forms routes?
rg -n "forms|items" src/pages/sponsors/sponsor-page/index.js

Repository: fntechgit/summit-admin

Length of output: 353


🏁 Script executed:

# Check the specific git commit about sponsor page routes refactoring
git show 674196c --stat | head -50

Repository: fntechgit/summit-admin

Length of output: 2984


🏁 Script executed:

# Verify if SponsorPage's /forms route properly handles the form_id/items path
sed -n '95,130p' src/pages/sponsors/sponsor-page/index.js

Repository: fntechgit/summit-admin

Length of output: 1176


Add backward compatibility redirect for legacy sponsor-forms routes.

The recent route refactoring changed the pattern from sponsor-forms to forms. With the catch-all <Route path={match.url} component={SponsorPage} /> at line 144, legacy links using /sponsor-forms/:form_id/items will reach SponsorPage but fail to match its internal route (/forms/:form_id/items), breaking existing bookmarks and deep links.

Add a redirect route before the catch-all to preserve backward compatibility:

Suggested redirect
-import { Switch, Route } from "react-router-dom";
+import { Switch, Route, Redirect } from "react-router-dom";
...
+          <Route
+            exact
+            path={`${match.url}/sponsor-forms/:form_id/items`}
+            render={(props) => (
+              <Redirect to={`${match.url}/forms/${props.match.params.form_id}/items`} />
+            )}
+          />
           <Route path={match.url} component={SponsorPage} />
📝 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
<Route path={match.url} component={SponsorPage} />
<Route
exact
path={`${match.url}/sponsor-forms/:form_id/items`}
render={(props) => (
<Redirect to={`${match.url}/forms/${props.match.params.form_id}/items`} />
)}
/>
<Route path={match.url} component={SponsorPage} />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/layouts/sponsor-id-layout.js` at line 144, The catch-all Route (Route
path={match.url} component={SponsorPage}) lets legacy
/sponsor-forms/:form_id/items requests reach SponsorPage but they no longer
match internal /forms/:form_id/items routes; add a Redirect before that
catch-all that rewrites legacy /sponsor-forms/:form_id/* to /forms/:form_id/* to
preserve deep links; place this Redirect immediately above the Route that
renders SponsorPage so it runs first and references the same match.url base and
SponsorPage routing behavior.

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.

🧹 Nitpick comments (1)
src/pages/sponsors/__tests__/edit-sponsor-page.test.js (1)

84-86: Remove the explicit act wrapper.

The project uses @testing-library/user-event v14.5.2, which automatically wraps user interactions in act(). The explicit wrapper on lines 84-86 is redundant.

      await userEvent.click(formsTab);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/__tests__/edit-sponsor-page.test.js` around lines 84 - 86,
Remove the redundant explicit act wrapper around the user interaction: locate
the test that calls await act(async () => { await userEvent.click(formsTab); });
and replace it by directly awaiting the user event call (await
userEvent.click(formsTab)); specifically remove the outer act(...) so
userEvent.click(formsTab) runs by itself since `@testing-library/user-event`
v14.5.2 already wraps interactions in act.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/pages/sponsors/__tests__/edit-sponsor-page.test.js`:
- Around line 84-86: Remove the redundant explicit act wrapper around the user
interaction: locate the test that calls await act(async () => { await
userEvent.click(formsTab); }); and replace it by directly awaiting the user
event call (await userEvent.click(formsTab)); specifically remove the outer
act(...) so userEvent.click(formsTab) runs by itself since
`@testing-library/user-event` v14.5.2 already wraps interactions in act.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d4a87744-2fd2-4e9e-a424-cf65276f6b1d

📥 Commits

Reviewing files that changed from the base of the PR and between 674196c and e11389f.

📒 Files selected for processing (2)
  • src/pages/sponsors/__tests__/edit-sponsor-page.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/tests/sponsor-pages-tab.test.js

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.

@santipalenque please review comments

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.

Actionable comments posted: 1

🤖 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/pages/sponsors/sponsor-page/tabDefs.js`:
- Around line 18-23: The Breadcrumb title is hardcoded as "Forms", breaking
i18n; change it to use the same i18n pattern as the tabDefs (e.g., use the
translation key used by this tab or call the translation function) so Breadcrumb
receives a localized string instead of a literal. Update the Breadcrumb
data.title to derive from the tab's labelKey or invoke the translation helper
used across the file (referencing Breadcrumb and the existing labelKey entries)
so the title is consistent with the other tab labels.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90381f99-ac21-43f0-926e-88923a7ed338

📥 Commits

Reviewing files that changed from the base of the PR and between e11389f and 91c4b9b.

📒 Files selected for processing (12)
  • src/pages/sponsors/sponsor-page/components/tab-nav.js
  • src/pages/sponsors/sponsor-page/index.js
  • src/pages/sponsors/sponsor-page/tabDefs.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-badge-scans/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-media-upload-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js
  • src/pages/sponsors/sponsor-users-list-per-sponsor/index.js
✅ Files skipped from review due to trivial changes (2)
  • src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-media-upload-tab/index.js
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/pages/sponsors/sponsor-page/tabs/sponsor-badge-scans/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/tests/sponsor-pages-tab.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-general-form/index.js
  • src/pages/sponsors/sponsor-page/index.js
  • src/pages/sponsors/sponsor-page/components/tab-nav.js
  • src/pages/sponsors/sponsor-users-list-per-sponsor/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/index.js

Comment on lines +18 to +23
<Breadcrumb
data={{
title: "Forms",
pathname: match.url
}}
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Hardcoded breadcrumb title breaks i18n consistency.

The "Forms" string is hardcoded while all tab definitions use labelKey for internationalization. Consider using a translation function or pattern consistent with the rest of the file.

Suggested fix
+import T from "i18n-react"; // or your i18n utility
+
 const SponsorFormsRoute = ({ match }) => (
   <div>
     <Breadcrumb
       data={{
-        title: "Forms",
+        title: T.translate("edit_sponsor.tab.forms"),
         pathname: match.url
       }}
     />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/sponsor-page/tabDefs.js` around lines 18 - 23, The
Breadcrumb title is hardcoded as "Forms", breaking i18n; change it to use the
same i18n pattern as the tabDefs (e.g., use the translation key used by this tab
or call the translation function) so Breadcrumb receives a localized string
instead of a literal. Update the Breadcrumb data.title to derive from the tab's
labelKey or invoke the translation helper used across the file (referencing
Breadcrumb and the existing labelKey entries) so the title is consistent with
the other tab labels.

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 72be57f into master Apr 7, 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