Skip to content

Complete OrbitStack qualifying tasks - #8

Open
Phloraxx wants to merge 6 commits into
MulearnMCE:masterfrom
Phloraxx:fix/orbitstack-challenge
Open

Complete OrbitStack qualifying tasks#8
Phloraxx wants to merge 6 commits into
MulearnMCE:masterfrom
Phloraxx:fix/orbitstack-challenge

Conversation

@Phloraxx

@Phloraxx Phloraxx commented Aug 13, 2026

Copy link
Copy Markdown

Submission checklist

Updated GitHub repository

https://github.com/Phloraxx/orbitstack/tree/fix/orbitstack-challenge

Working version

The application is working on the submitted branch and was verified with the test suite, TypeScript checks, Prisma validation, and a production Next.js build.

Bugs identified

  • Pro free-shipping and a stackable free-shipping discount could apply the same shipping benefit twice through discountCents.
  • Dashboard order history used an N+1 query pattern, causing query count to grow with the number of orders.
  • Past orders had no Duplicate Order flow for safely re-adding currently available products to the cart.

Fixes implemented

  • Corrected pricing so free shipping is represented only through shippingCents = 0 and is not credited again as a monetary discount.
  • Replaced per-order item queries with a Prisma relation query, limited dashboard history to the most recent 30 days, and added a compound (userId, createdAt) index.
  • Added POST /api/orders/[id]/duplicate with authentication, 404 for missing orders, 403 for wrong-owner requests, current product/stock checks, and the existing { data, error } response envelope.
  • Added the dashboard Duplicate Order action and a batched Zustand cart update that merges eligible items into the current persisted cart.

Remaining bugs / incomplete features

  • No known blockers remain for the three requested challenge tasks.
  • Duplicate Order currently re-adds an order line only when the full original quantity is available. Stock is validated again during checkout because inventory can change while items remain in the cart.
  • Repository-wide npm run lint still reports 7 pre-existing errors and 4 warnings in unrelated UI/hydration/link code. These were present outside the challenge changes; changed-file lint passes and the production build succeeds.

Run locally

npm ci
cp .env.example .env
npm run dev

Then open http://localhost:3000.

Verification

  • npm test — 9/9 tests passed
  • npx tsc --noEmit — passed
  • focused ESLint checks on changed source/test files — passed
  • npx prisma validate — passed
  • npm run build — passed
  • git diff --check — passed

AI usage is documented in AI_LOG.md.

Screenshots/demo video were not included because they are optional in the challenge brief.

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