Skip to content

Feature: show level purchases view#949

Open
santipalenque wants to merge 2 commits into
masterfrom
feature/show-level-sponsor-orders
Open

Feature: show level purchases view#949
santipalenque wants to merge 2 commits into
masterfrom
feature/show-level-sponsor-orders

Conversation

@santipalenque
Copy link
Copy Markdown

@santipalenque santipalenque commented May 19, 2026

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

Summary by CodeRabbit

  • New Features

    • Added a sponsor purchases management page with search, sorting, pagination, and details view
    • Added export-to-CSV for purchases
    • Added in-list approve/reject controls for purchase status
    • Added a "Purchases" menu item under Sponsors
  • Style

    • Updated UI styling for purchase controls and buttons
  • Documentation

    • Updated English labels and placeholders for search and purchases list columns

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb601404-70bc-4e82-847c-c494cf550f5f

📥 Commits

Reviewing files that changed from the base of the PR and between cb2f3f7 and f60c5c7.

📒 Files selected for processing (2)
  • src/pages/sponsors/show-pages-list-page/__tests__/show-pages-list-page.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/__tests__/sponsor-purchases-list.test.js

📝 Walkthrough

Walkthrough

Adds a sponsor purchases management feature: new Redux actions and CSV export, reducer and store slice, a purchases list page with search/pagination/sort and inline approve/reject, routing/menu/translations, and corresponding UI/tests updates.

Changes

Sponsor Purchases List Feature

Layer / File(s) Summary
Redux action contract
src/actions/sponsor-purchases-actions.js
New action constants REQUEST_ALL_SPONSOR_PURCHASES and RECEIVE_ALL_SPONSOR_PURCHASES; getAllSponsorPurchases and exportAllSponsorPurchases implemented (filtering, pagination, CSV export); approveSponsorPurchase / rejectSponsorPurchase signatures updated to accept sponsorId and use it in API URLs.
Redux reducer and store
src/reducers/sponsors/show-purchase-list-reducer.js, src/store.js
New reducer showPurchaseListReducer with pagination/sort defaults, request/receive/status-update handling (formats dates, converts cents), exported and registered as showPurchaseListState in the persisted root reducer.
Purchase list page component
src/pages/sponsors/show-purchase-list-page/index.js
ShowPurchaseListPage fetches purchases on mount and supports search, pagination, sorting, CSV export, details navigation, and inline status updates that dispatch approve/reject actions; connected to Redux.
Routing, menu, and translations
src/layouts/sponsor-layout.js, src/components/menu/menu-definition.js, src/i18n/en.json
Adds ${match.url}/purchases route (lazy-loaded), new "Purchases" menu item under sponsors, and English translations for menu label and purchase table headers.
Existing UI and tests updates
src/pages/sponsors/show-pages-list-page/index.js, src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js, src/pages/sponsors/.../__tests__/*
ShowPagesListPage adds breadcrumb using match.url; SponsorPurchasesTab adjusts status-change call signatures and button styling; tests updated to pass match prop and to expect updated approve/reject call signatures.

Sequence Diagram

sequenceDiagram
  participant Page as ShowPurchaseListPage
  participant Redux as Redux (actions/store)
  participant API as API
  Page->>Redux: mount() → getAllSponsorPurchases(term,page,perPage,order,orderDir)
  Redux->>Redux: dispatch REQUEST_ALL_SPONSOR_PURCHASES
  Redux->>API: GET /api/public/v1/summits/{id}/sponsors/purchases?filters...
  API-->>Redux: returns purchases array
  Redux->>Redux: dispatch RECEIVE_ALL_SPONSOR_PURCHASES
  Redux-->>Page: state update triggers re-render with purchases
  Page->>Redux: user selects status → approveSponsorPurchase(sponsorId,paymentId) or rejectSponsorPurchase(sponsorId,paymentId)
  Redux->>API: POST /api/public/v1/summits/{id}/sponsors/{sponsorId}/payments/{paymentId}/approve or /cancel
  API-->>Redux: purchase status updated
  Redux-->>Page: updated purchase status reflected in table
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • romanetar
  • smarcet

Poem

🐰 I hopped through code with curious paws,
Added lists, filters, and CSV laws,
Approve and reject now take an ID,
Breadcrumbs guide where admins should be,
Hooray — purchases managed without pause! 🥕

🚥 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 'Feature: show level purchases view' directly describes the main objective of the PR - adding a new purchases view at the show level. It is clear, specific, and accurately summarizes the primary change.
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 feature/show-level-sponsor-orders

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

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

Inline comments:
In `@src/actions/sponsor-purchases-actions.js`:
- Around line 95-103: The current promise chain calling
getRequest(createAction(REQUEST_ALL_SPONSOR_PURCHASES),
createAction(RECEIVE_ALL_SPONSOR_PURCHASES), ...)(params)(dispatch) only
dispatches stopLoading() inside .then(...), so on failures the global loading
state can remain set; change the chain to ensure stopLoading() is dispatched in
all outcomes (use .finally(() => dispatch(stopLoading())) or add a .catch(err =>
{ /* optional handle */; throw err; }).finally(...) ) so that stopLoading() is
always dispatched after the getRequest call, keeping createAction, getRequest,
and stopLoading usage intact.

In `@src/pages/sponsors/show-pages-list-page/index.js`:
- Around line 184-191: The JSX unguarded access to match.url can throw if match
is undefined; update the Breadcrumb data to use a safe fallback (e.g., use
optional chaining and a default: pathname: match?.url || '' or match?.path ||
'') or ensure the component is wrapped with withRouter so match is always
injected; locate the Breadcrumb usage and replace direct match.url with the
guarded expression (or add withRouter to the component export) to prevent the
TypeError.

In `@src/pages/sponsors/show-purchase-list-page/index.js`:
- Around line 90-92: The menu handler handleMenu currently only console.logs the
item, leaving a dead UI control and leaking payloads; replace the debug log with
a real action or disable the control: implement a meaningful handler (e.g., call
a passed prop like onMenuSelect(item), open the purchase details modal, or
trigger navigation to the purchase view) and remove the console.log, and if no
action is available remove the menu rendering or render a disabled menu entry so
users cannot interact with it; also apply the same change to the other menu
handler block that mirrors this behavior.
- Around line 78-80: handleExport currently calls exportAllSponsorPurchases()
with no context so the exported CSV ignores the current term, order, and
orderDir; update handleExport to pass the current filter/sort state (term,
order, orderDir) to exportAllSponsorPurchases (or read them from the same state
object it uses) so the export mirrors the table view—refer to the handleExport
function and the exportAllSponsorPurchases function and ensure they accept and
forward those parameters.
🪄 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: 28b8f85e-d7de-43cf-9bc9-62bd810a332f

📥 Commits

Reviewing files that changed from the base of the PR and between 30c2c8a and cb2f3f7.

📒 Files selected for processing (9)
  • src/actions/sponsor-purchases-actions.js
  • src/components/menu/menu-definition.js
  • src/i18n/en.json
  • src/layouts/sponsor-layout.js
  • src/pages/sponsors/show-pages-list-page/index.js
  • src/pages/sponsors/show-purchase-list-page/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js
  • src/reducers/sponsors/show-purchase-list-reducer.js
  • src/store.js

Comment on lines +95 to +103
return getRequest(
createAction(REQUEST_ALL_SPONSOR_PURCHASES),
createAction(RECEIVE_ALL_SPONSOR_PURCHASES),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/purchases`,
authErrorHandler,
{ order, orderDir, page, perPage, term }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
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 | 🟠 Major | ⚡ Quick win

Ensure loading state is cleared on request failures.

At Line 95, stopLoading() only runs in .then(...). If the request fails, global loading can remain stuck.

💡 Suggested fix
-    return getRequest(
+    return getRequest(
       createAction(REQUEST_ALL_SPONSOR_PURCHASES),
       createAction(RECEIVE_ALL_SPONSOR_PURCHASES),
       `${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/purchases`,
       authErrorHandler,
       { order, orderDir, page, perPage, term }
-    )(params)(dispatch).then(() => {
-      dispatch(stopLoading());
-    });
+    )(params)(dispatch).finally(() => {
+      dispatch(stopLoading());
+    });
📝 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
return getRequest(
createAction(REQUEST_ALL_SPONSOR_PURCHASES),
createAction(RECEIVE_ALL_SPONSOR_PURCHASES),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/purchases`,
authErrorHandler,
{ order, orderDir, page, perPage, term }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
return getRequest(
createAction(REQUEST_ALL_SPONSOR_PURCHASES),
createAction(RECEIVE_ALL_SPONSOR_PURCHASES),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/purchases`,
authErrorHandler,
{ order, orderDir, page, perPage, term }
)(params)(dispatch).finally(() => {
dispatch(stopLoading());
});
🤖 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-purchases-actions.js` around lines 95 - 103, The current
promise chain calling getRequest(createAction(REQUEST_ALL_SPONSOR_PURCHASES),
createAction(RECEIVE_ALL_SPONSOR_PURCHASES), ...)(params)(dispatch) only
dispatches stopLoading() inside .then(...), so on failures the global loading
state can remain set; change the chain to ensure stopLoading() is dispatched in
all outcomes (use .finally(() => dispatch(stopLoading())) or add a .catch(err =>
{ /* optional handle */; throw err; }).finally(...) ) so that stopLoading() is
always dispatched after the getRequest call, keeping createAction, getRequest,
and stopLoading usage intact.

Comment on lines +184 to +191
<div>
<Breadcrumb
data={{
title: T.translate("show_pages.pages"),
pathname: match.url
}}
/>
</div>
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 | 🔴 Critical | ⚡ Quick win

Critical: Unchecked access to match.url causes runtime error.

The code accesses match.url without verifying that match exists, causing test failures as confirmed by the pipeline. If the component is rendered without the match prop, this will throw a TypeError.

🐛 Proposed fix using optional chaining
       <Breadcrumb
         data={{
           title: T.translate("show_pages.pages"),
-          pathname: match.url
+          pathname: match?.url
         }}
       />

Alternatively, if match is always expected from React Router, ensure the component is wrapped with withRouter HOC or verify the parent route passes match correctly.

📝 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
<div>
<Breadcrumb
data={{
title: T.translate("show_pages.pages"),
pathname: match.url
}}
/>
</div>
<div>
<Breadcrumb
data={{
title: T.translate("show_pages.pages"),
pathname: match?.url
}}
/>
</div>
🧰 Tools
🪛 GitHub Actions: jest / 0_build.txt

[error] 188-188: TypeError: Cannot read properties of undefined (reading 'url') at pathname: match.url (ShowPagesListPage tests fail).

🪛 GitHub Actions: jest / build

[error] 188-188: TypeError: Cannot read properties of undefined (reading 'url'). Error occurs at pathname: match.url (src/pages/sponsors/show-pages-list-page/index.js:188:29), causing ShowPagesListPage tests to fail.

🤖 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/pages/sponsors/show-pages-list-page/index.js` around lines 184 - 191, The
JSX unguarded access to match.url can throw if match is undefined; update the
Breadcrumb data to use a safe fallback (e.g., use optional chaining and a
default: pathname: match?.url || '' or match?.path || '') or ensure the
component is wrapped with withRouter so match is always injected; locate the
Breadcrumb usage and replace direct match.url with the guarded expression (or
add withRouter to the component export) to prevent the TypeError.

Comment on lines +78 to +80
const handleExport = () => {
exportAllSponsorPurchases();
};
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 | 🟠 Major | ⚡ Quick win

Pass current filters/sort when exporting CSV.

At Line 79, export ignores current term, order, and orderDir, so downloaded data can differ from what the table is showing.

💡 Suggested fix
   const handleExport = () => {
-    exportAllSponsorPurchases();
+    exportAllSponsorPurchases(term, order, orderDir);
   };
📝 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
const handleExport = () => {
exportAllSponsorPurchases();
};
const handleExport = () => {
exportAllSponsorPurchases(term, order, orderDir);
};
🤖 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/pages/sponsors/show-purchase-list-page/index.js` around lines 78 - 80,
handleExport currently calls exportAllSponsorPurchases() with no context so the
exported CSV ignores the current term, order, and orderDir; update handleExport
to pass the current filter/sort state (term, order, orderDir) to
exportAllSponsorPurchases (or read them from the same state object it uses) so
the export mirrors the table view—refer to the handleExport function and the
exportAllSponsorPurchases function and ensure they accept and forward those
parameters.

Comment on lines +90 to +92
const handleMenu = (item) => {
console.log("MENU : ", item);
};
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 | ⚡ Quick win

Avoid shipping a non-functional menu action with debug logging.

At Line 91 the menu action only logs row data; this leaves a dead UI control and exposes row payloads in the browser console.

💡 Suggested fix
-  const handleMenu = (item) => {
-    console.log("MENU : ", item);
-  };
+  const handleMenu = () => {};
-    {
-      columnKey: "menu",
-      header: "",
-      width: 100,
-      align: "center",
-      render: (row) => (
-        <IconButton
-          size="large"
-          sx={{ color: "primary.main" }}
-          onClick={() => handleMenu(row)}
-        >
-          <MenuIcon fontSize="large" />
-        </IconButton>
-      )
-    }
+    // TODO: add this column back when menu actions are implemented

Also applies to: 173-186

🤖 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/pages/sponsors/show-purchase-list-page/index.js` around lines 90 - 92,
The menu handler handleMenu currently only console.logs the item, leaving a dead
UI control and leaking payloads; replace the debug log with a real action or
disable the control: implement a meaningful handler (e.g., call a passed prop
like onMenuSelect(item), open the purchase details modal, or trigger navigation
to the purchase view) and remove the console.log, and if no action is available
remove the menu rendering or render a disabled menu entry so users cannot
interact with it; also apply the same change to the other menu handler block
that mirrors this behavior.

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