Skip to content

Conversation

@santipalenque
Copy link

@santipalenque santipalenque commented Jan 12, 2026

https://app.clickup.com/t/86b82f0x3
https://app.clickup.com/t/86b82f1bz

Summary by CodeRabbit

  • New Features
    • Sponsor cart forms can be locked and unlocked individually to control access during editing and review.
  • Improvements
    • Deleting a sponsor cart form shows a success notification and automatically refreshes cart data for a smoother workflow.
    • Lock/unlock actions are integrated into the sponsor cart UI as a per-form toggle.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

Adds lock/unlock and delete actions for sponsor cart forms, integrates them into the SponsorCartTab UI, and updates the cart-list reducer to track per-form is_locked state and respond to SPONSOR_CART_FORM_LOCKED actions.

Changes

Cohort / File(s) Summary
Action Layer
src/actions/sponsor-cart-actions.js
Adds SPONSOR_CART_FORM_LOCKED export; implements lockSponsorCartForm(formId) (PUT via putRequest), unlockSponsorCartForm(formId) (DELETE via deleteRequest), and deleteSponsorCartForm(formId) flows; uses token retrieval, updates loading/error states, refreshes cart and shows snackbar.
Component Integration
src/pages/sponsors/sponsor-cart-tab/index.js
Wires lockSponsorCartForm and unlockSponsorCartForm into SponsorCartTab props and connect; replaces static lock handling with per-form form.is_locked toggle calling the new actions.
State Management / Reducer
src/reducers/sponsors/sponsor-page-cart-list-reducer.js
Imports SPONSOR_CART_FORM_LOCKED and handles it by immutably updating the matching form's is_locked flag inside cart.forms, mirroring existing delete-case update pattern.

Sequence Diagram

sequenceDiagram
    participant User
    participant Component as SponsorCartTab
    participant Action as Action Creator
    participant API as Sponsor Users API
    participant Store as Redux Store
    participant Reducer as Cart List Reducer

    User->>Component: click lock/unlock on form
    Component->>Action: dispatch lockSponsorCartForm(formId) / unlockSponsorCartForm(formId)
    Action->>API: PUT / DELETE /forms/{formId}/lock (with token)
    API-->>Action: 200 OK (is_locked true/false)
    Action->>Store: dispatch SPONSOR_CART_FORM_LOCKED (formId, is_locked)
    Store->>Reducer: process action
    Reducer->>Store: return updated cart state (forms[].is_locked updated)
    Store-->>Component: new state
    Component-->>User: render updated lock state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: sponsor cart view #748 — Modifies the same sponsor cart actions, SponsorCartTab, and reducer; likely overlaps or precedes these changes.

Suggested reviewers

  • smarcet

Poem

🐰 I nudged a form and gave it a lock,
Hopped through endpoints — PUT then knock,
Dispatch a flag, the cart complies,
Forms snooze tight or open eyes,
Carrots, keys, and tidy stocks 🥕🔐

🚥 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 clearly and concisely summarizes the main changes: adding lock and delete functionality for sponsor cart forms, which matches the substantial additions of three new action creators and reducer handling.
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

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: 2

🤖 Fix all issues with AI agents
In @src/actions/sponsor-cart-actions.js:
- Around line 119-143: lockSponsorCartForm currently dispatches the putRequest
promise but does not return it, preventing callers from awaiting or chaining;
update lockSponsorCartForm to return the putRequest(...) invocation (the same
expression ending with (params)(dispatch)) so the function returns the promise
chain and retains the existing .catch/.finally behavior; locate the
lockSponsorCartForm export and add the return in front of the putRequest call.

In @src/reducers/sponsors/sponsor-page-cart-list-reducer.js:
- Around line 74-91: The reducer branch for SPONSOR_CART_FORM_LOCKED is
inconsistent with other branches and the UI: update the mapping in the
SPONSOR_CART_FORM_LOCKED case to compare against form.form_id (not form.id) and
set the lock flag on the form object as is_locked instead of locked; e.g., in
the forms = state.cart.forms.map callback for SPONSOR_CART_FORM_LOCKED return
{...form, is_locked: locked} when form.form_id === formId so the UI reads the
updated property, keeping SPONSOR_CART_FORM_DELETED and other cases using
form.form_id for ID comparisons.
🧹 Nitpick comments (2)
src/actions/sponsor-cart-actions.js (2)

138-142: Improve error handling for better debugging and consistency.

Using .catch(console.log) swallows errors silently without user feedback. Since snackbarErrorHandler is already configured, the catch block may be redundant or could be improved.

Suggested improvement
   )(params)(dispatch)
-    .catch(console.log) // need to catch promise reject
+    .catch((err) => {
+      console.error("Lock sponsor cart form failed:", err);
+    })
     .finally(() => {
       dispatch(stopLoading());
     });

105-112: Consider awaiting getSponsorCart before showing success message.

The success snackbar displays before the cart refresh completes. Consider awaiting to ensure the UI updates before confirming success.

Suggested improvement
     .then(() => {
-      getSponsorCart()(dispatch, getState);
+      return getSponsorCart()(dispatch, getState);
+    })
+    .then(() => {
       dispatch(
         snackbarSuccessHandler({
           title: T.translate("general.success"),
           html: T.translate("sponsor_forms.form_delete_success")
         })
       );
     })
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9ae9ce and 06ab7c0.

📒 Files selected for processing (3)
  • src/actions/sponsor-cart-actions.js
  • src/pages/sponsors/sponsor-cart-tab/index.js
  • src/reducers/sponsors/sponsor-page-cart-list-reducer.js
🧰 Additional context used
🧬 Code graph analysis (2)
src/reducers/sponsors/sponsor-page-cart-list-reducer.js (2)
src/actions/sponsor-cart-actions.js (2)
  • SPONSOR_CART_FORM_LOCKED (32-32)
  • SPONSOR_CART_FORM_LOCKED (32-32)
src/reducers/sponsors/sponsor-forms-list-reducer.js (1)
  • form (120-120)
src/actions/sponsor-cart-actions.js (2)
src/utils/methods.js (2)
  • getAccessTokenSafely (128-135)
  • getAccessTokenSafely (128-135)
src/components/forms/sponsor-general-form/sponsorship.js (1)
  • sponsor (38-45)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (4)
src/actions/sponsor-cart-actions.js (1)

135-135: Verify the API base URL difference is intentional.

deleteSponsorCartForm uses PURCHASES_API_URL while lockSponsorCartForm and unlockSponsorCartForm use SPONSOR_USERS_API_URL. Ensure this is the intended API architecture.

Also applies to: 157-157

src/pages/sponsors/sponsor-cart-tab/index.js (3)

71-77: Lock toggle logic is correctly implemented.

The toggle logic properly checks is_locked and calls the appropriate action. However, this depends on the reducer fix mentioned earlier—the reducer currently sets locked instead of is_locked, which will prevent the UI from updating after lock/unlock operations.


128-140: LGTM!

The lock column rendering correctly toggles between LockClosedIcon and LockOpenIcon based on the is_locked state, and the click handler properly passes the full row object to handleLock.


236-241: LGTM!

The new lockSponsorCartForm and unlockSponsorCartForm actions are correctly wired in the connect call.


const forms = state.cart.forms.map((form) => {
if (form.form_id === formId) {
return {...form, locked};
Copy link

Choose a reason for hiding this comment

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

@santipalenque here is form.locked but at ui is form.is_locked

@fntechgit fntechgit deleted a comment from coderabbitai bot Jan 23, 2026
const { formId, locked } = payload;

const forms = state.cart.forms.map((form) => {
if (form.form_id === formId) {
Copy link

Choose a reason for hiding this comment

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

@santipalenque here u use from.form_id but at here

const forms = state.cart.forms.filter((form) => form.id !== formId);
u use form.id so seems there is a mismatch

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.

@santipalenque please review

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

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 638e576 into master Jan 23, 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.

3 participants