Skip to content

Cleanup Store checkout#270

Merged
devksingh4 merged 4 commits intomainfrom
dsingh14/cleanup-store-checkout
Jan 31, 2026
Merged

Cleanup Store checkout#270
devksingh4 merged 4 commits intomainfrom
dsingh14/cleanup-store-checkout

Conversation

@devksingh4
Copy link
Member

@devksingh4 devksingh4 commented Jan 30, 2026

Summary by CodeRabbit

  • New Features

    • Per-variant member pricing and active-variant selection UI
    • Membership status panel with cached status and automatic updates on login/logout
    • Security verification widget integrated into checkout
    • Per-variant quantity caps and improved sold-out handling
  • Bug Fixes

    • Unified API error handling and user-facing error/verification modal
    • UI tweaks: clearer sold-out labels, disabled options, and quantity input feedback

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

@devksingh4 devksingh4 requested review from a team as code owners January 30, 2026 07:05
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Adds per-variant membership support to the merch product page: introduces a Variant type, computes activeMemberLists from the selected variant or uniform lists across variants, and adds membership checks with an in-memory membershipCache, activeMembershipKey guarding async responses, and caching invalidation on login/logout. Integrates membership-aware pricing and UI (shouldShowMembershipStatus, renderMembershipStatus), per-variant max-quantity calculation (getMaxQuantity), Turnstile verification and token handling, unified API error payload handling with 404 behavior, and an error/verification modal. Also makes ApiVariant.memberLists optional and defaults LegacyItem.memberLists to an empty array.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Cleanup Store checkout' is vague and does not clearly describe the main changes, which involve significant refactoring of membership checking, per-variant pricing, error handling, and UI enhancements. Consider a more descriptive title that captures the key changes, such as 'Add per-variant membership and pricing logic to merch checkout' or 'Refactor merch store with variant-specific membership checks and caching'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dsingh14/cleanup-store-checkout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link

github-actions bot commented Jan 30, 2026

Deploying with Cloudflare Pages

Name Result
Last commit: 37da8c6
Preview URL: https://607f37a5.acmuiuc.pages.dev
Branch Preview URL: https://dsingh14-cleanup-store-check.acmuiuc.pages.dev

Copy link
Contributor

@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

Caution

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

⚠️ Outside diff range comments (1)
src/app/(membership)/merch/page.tsx (1)

159-172: ⚠️ Potential issue | 🟠 Major

Non‑404 product fetch failures are silently ignored.

If the API returns anything other than 404, the UI remains blank and no modal opens. Route those errors through the shared handler (and mark the fetch as failed so the close handler can redirect).

🔧 Suggested fix
     .catch((error) => {
       if (error.response && error.response.status === 404) {
         setTimeout(() => {
           setErrorMessage({
             title: "Error retrieving product",
             code: 404,
             message: error.response.data.message,
           });
           setMerchList({ failed: true });
           setIsLoading(false);
           modalErrorMessage.onOpen();
         }, 1000);
+      } else {
+        setMerchList({ failed: true });
+        handleApiError(error);
       }
     });
🤖 Fix all issues with AI agents
In `@src/app/`(membership)/merch/page.tsx:
- Around line 324-329: validateQuantity currently allows positive quantities
even when getMaxQuantity(size) returns 0; update the function so that after
computing const maxQty = getMaxQuantity(size) it returns false when maxQty === 0
(i.e., treat zero availability as invalid for a selected size). Keep the
existing NaN and >max checks, but add the explicit maxQty === 0 check
(referencing validateQuantity, getMaxQuantity, size, and maxQty) so any attempt
to pick a quantity when a size has zero stock is rejected.
- Around line 457-517: The purchase flow must be blocked while membership status
is unresolved: update the main purchase Button (the component using
onPress={purchaseHandler} and props isDisabled and isLoading) to also disable
when isPaidMember === null (e.g., include "|| isPaidMember === null" in its
isDisabled expression) and optionally change the button label to indicate
membership check (e.g., show "Checking membership..." when isPaidMember ===
null); ensure any client-side validation that gates purchase (isFormValidated,
totalCapacity(), isLoading) remains intact.
- Around line 539-552: Selected size display names are being stored/used as
variantIds (causing failures in getMaxQuantity and checkout); map the selected
display name back to its actual variantId from merchList.variants and use that
variantId for validation and payloads: update changeSize (or introduce a helper)
to look up merchList.variants for the id given the name, store the variantId in
size (or keep both name/id), and ensure getMaxQuantity reads
merchList.total_avail[variantId] and checkout payloads send variantId (not the
display name). Reference: Select/SelectItem, changeSize, getMaxQuantity,
merchList.total_avail and merchList.variants.

Copy link
Contributor

@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

Caution

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

⚠️ Outside diff range comments (1)
src/app/(membership)/merch-store/transform.ts (1)

34-47: 🧹 Nitpick | 🔵 Trivial

Type variants to include memberLists for stronger guarantees.

UI code now consumes variant.memberLists, but LegacyItem doesn’t declare a variants shape, so you lose type checking. Consider typing it explicitly.

🔧 Suggested type update
 interface LegacyItem {
   member_price: string;
   nonmember_price: string;
   item_image: string;
   sizes: string[];
   item_price: { paid: number; others: number };
   eventDetails: string;
   item_id: string;
   total_sold: Record<string, number>;
   total_avail: Record<string, number>;
   limit_per_person: number;
   item_sales_active_utc: number;
   item_name: string;
+  variants?: { id: string; name: string; memberLists: string[] }[];
 }

Also applies to: 96-100

🤖 Fix all issues with AI agents
In `@src/app/`(membership)/merch/page.tsx:
- Around line 113-117: Guard against stale async membership checks by
introducing an "active cache key" ref and resetting member state when a new
check begins: create a ref like activeMembershipKeyRef = useRef<string |
null>(null), set activeMembershipKeyRef.current to the cache key whenever you
start a membership lookup (before calling setIsCheckingMembership(true) and
before early-return using membershipCache), clear/set setIsPaidMember(false)
when a new check starts, and when the async call resolves only apply
setIsPaidMember(result) and membershipCache.set(key, result) if
activeMembershipKeyRef.current === key (ignore/stale otherwise); also clear
activeMembershipKeyRef.current and setIsCheckingMembership(false) after handling
the response. Ensure this pattern replaces direct uses of membershipCache,
isCheckingMembership, setIsCheckingMembership and setIsPaidMember in the
membership lookup logic so out-of-order responses for the previous variant are
ignored.
- Around line 226-233: getMaxQuantity currently assumes merchList.total_avail
has per-variant keys and returns 0 when merchList.total_avail[variantId] is
missing; change it to treat PER_PRODUCT inventory by falling back to
merchList.total_avail.total when the variantId entry is absent — compute
available as Math.min((merchList.total_avail[variantId] ||
merchList.total_avail.total || 0), 10) and then apply merchList.limit_per_person
cap (using Math.min) before returning; update the logic inside getMaxQuantity to
use that fallback.

devksingh4 and others added 2 commits January 31, 2026 12:59
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@devksingh4 devksingh4 merged commit 4975435 into main Jan 31, 2026
4 of 5 checks passed
@devksingh4 devksingh4 deleted the dsingh14/cleanup-store-checkout branch January 31, 2026 19:01
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