Task #19: Donation cart (سلة تبرعاتك) for EHSAN POC

Built a real donation cart matching ehsan.sa:
- CartContext provider (localStorage-persisted, defensive parsing) wired into App.tsx
- OpportunityCard: cart icon now adds the case with its typed amount and swaps the
  action row to an added state («مضاف لسلة تبرعاتك» + «إزالة»)
- Header cart button: live count badge + navigates to /cart
- New /cart page + route: breadcrumb, item list (delete icon, category, name,
  editable «قيمة المبلغ» amount, image+progress%), summary panel «الإجمالي» +
  green «للمتابعة للدفع», decorative leaf SVG background, empty state
- translations.ts: parallel AR+EN `cart` section
- donate.tsx: removes the donated case from the cart on successful donation
  (cart reconciliation), preventing stale added-state/badge

Notes/deviations:
- Checkout handoff routes the first cart item into the existing single-case donate
  flow (the POC backend has no multi-item payment). Reconciliation keeps remaining
  items coherent. A true multi-item checkout backend was out of scope.
- Verified with passing e2e test (add → badge → cart page → remove → empty) and
  clean tsc; architect review addressed (reconciliation + defensive parsing).
This commit is contained in:
Replit Agent
2026-06-05 19:54:45 +00:00
parent b37e5fdfdb
commit d0d504bc74
8 changed files with 388 additions and 42 deletions
@@ -236,6 +236,19 @@ export const en = {
paymentTitle: "Payment Details",
selectAmountError: "Please select or enter a valid amount.",
},
cart: {
title: "Your Donation Cart",
breadcrumbHome: "Home",
amountLabel: "Amount value",
remove: "Remove",
added: "Added to your donation cart",
addToCart: "Add to cart",
total: "Total",
proceedToPayment: "Proceed to Payment",
empty: "Your donation cart is empty",
emptyHint: "Browse the available opportunities and add the causes you wish to support.",
browse: "Browse Opportunities",
},
admin: {
title: "Admin Dashboard",
caseId: "Case ID",
@@ -525,6 +538,19 @@ export const ar = {
paymentTitle: "بيانات الدفع",
selectAmountError: "الرجاء اختيار أو إدخال مبلغ صحيح.",
},
cart: {
title: "سلة تبرعاتك",
breadcrumbHome: "الرئيسية",
amountLabel: "قيمة المبلغ",
remove: "إزالة",
added: "مضاف لسلة تبرعاتك",
addToCart: "أضف للسلة",
total: "الإجمالي",
proceedToPayment: "للمتابعة للدفع",
empty: "سلة تبرعاتك فارغة",
emptyHint: "تصفّح الفرص المتاحة وأضف القضايا التي ترغب بدعمها.",
browse: "تصفّح الفرص",
},
admin: {
title: "لوحة الإدارة",
caseId: "رقم الحالة",