Skip to content

fix: complete OrbitStack qualifying tasks - #4

Open
sanjay-sanju-03 wants to merge 2 commits into
MulearnMCE:masterfrom
sanjay-sanju-03:fix/orbitstack-challenge
Open

fix: complete OrbitStack qualifying tasks#4
sanjay-sanju-03 wants to merge 2 commits into
MulearnMCE:masterfrom
sanjay-sanju-03:fix/orbitstack-challenge

Conversation

@sanjay-sanju-03

Copy link
Copy Markdown

Completed Tasks

Task 1 — Pricing Logic

  • Fixed the Pro + stackable free-shipping pricing bug.
  • Prevented shipping savings from being double-counted.
  • Added 6 pricing tests.

Task 2 — Dashboard Performance

  • Removed the N+1 query pattern from order history.
  • Optimized Prisma relation loading.

Task 3 — Duplicate Order

  • Added Duplicate Order API.
  • Added ownership and stock validation.
  • Added Duplicate Order button to the dashboard.
  • Integrated with the Zustand cart.

Validation

  • Pricing tests: 6/6 passing
  • TypeScript: 0 errors
  • AI usage documented in AI_LOG.md

Task 1 - Fix pricing logic bug (calculator.ts)
Pro user above threshold + stackable free-shipping coupon was incorrectly
adding STANDARD_SHIPPING_RATE to discountCents even though shipping was
already zeroed by the Pro threshold. Fix: gate on !proThresholdFreeShipping.
Added tests/pricing.test.ts with 6 cases covering all tier/coupon combos.

Task 2 - Fix N+1 query (queries.ts)
listOrders() was firing one OrderItem.findMany per order. Replaced with
Prisma nested include to eliminate per-order round-trips.

Task 3 - Duplicate Order feature
POST /api/orders/[id]/duplicate: ownership at DB level, validates active
status and full-quantity stock, returns items+quantities and skipped list.
DuplicateOrderButton.tsx: client island with loading/success/error states.
OrderCard.tsx: renders DuplicateOrderButton in card footer.
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