EHSAN official look & auth (Task #5)

Reskin the EHSAN POC to match ehsan.sa and gate the admin area behind a
simple POC login.

- Official header: cropped EHSAN logo, nav (الرئيسية/الوقف/فرص التبرع/
  خدماتنا dropdown→طلب دعم/عن إحسان/براعم إحسان), login/cart/search icons,
  language toggle, mobile menu. Functional items link; rest are visual-only.
- Colors: green primary tuned + orange accent token added in index.css.
- Auth: AuthContext (localStorage, admin/admin) + login page; /admin and
  /whatsapp-log now behind a Protected wrapper redirecting to /login.
- Redesigned OpportunityCard (photo, green progress bar with %, category
  badge, تم جمع/المبلغ المتبقي columns, inline donate button + amount),
  used on home and opportunities pages.
- Two-step donate page (التفاصيل → الدفع): step indicator, presets
  100/50/10, custom amount (prefilled via ?amount=), "تبرع عن أهلك"
  checkbox, donor form (phone min 10 for OpenClaw loop).
- 8 need-type card images added; needImages helper maps need→image.
- Seed: added published opportunities (req-012..017) with partial progress
  to showcase cards; one kept near-full for an easy closed-loop demo.

Deviation (from code review): donate handler now ACCUMULATES collectedAmount
and clamps to target, validates finite/positive amount, and only advances to
the closed-loop pipeline when a case is fully funded (previously overwrote
and force-advanced — broke partial-progress cases). Donate buttons kept green
to match the reference; orange is an accent only.
This commit is contained in:
Replit Agent
2026-06-05 17:45:17 +00:00
parent 4db9f09195
commit 5d40b0d3c2
28 changed files with 1177 additions and 324 deletions
+2
View File
@@ -0,0 +1,2 @@
- [Donate semantics](donate-semantics.md) — donations accumulate + clamp to target; a case enters the closed-loop pipeline only when fully funded.
- [api-server data](api-server-data.md) — mockDb is in-memory and mutated by POST calls; restart the workflow to reset to clean seed for demos.
+14
View File
@@ -0,0 +1,14 @@
---
name: api-server data
description: Nature of the EHSAN POC api-server data store and how to reset it.
---
# In-memory mockDb
`artifacts/api-server` serves an in-memory `mockDb` (no real database). Any POST that
mutates a request (donate, verify, publish, deliver, thank-you, etc.) persists only for
the life of the process. Restart the `artifacts/api-server: API Server` workflow to
re-seed clean demo data.
**How to apply:** after running curl-based API tests that mutate state, restart the
api-server workflow before screenshots/handoff so the user sees a clean seeded demo.
+21
View File
@@ -0,0 +1,21 @@
---
name: Donate semantics
description: How donations affect a request's collectedAmount and status in the EHSAN POC.
---
# Donate accounting & pipeline transition
On `POST /requests/:id/donate`, the server **adds** the donation to `collectedAmount`
(never overwrites it), clamps the applied amount to the remaining target, rejects
non-finite/non-positive amounts and cases that are not `published` / already funded.
A case only transitions out of `published` into the closed-loop pipeline (`donated`
→ delivered → … → whatsapp_sent → closed) once `collectedAmount >= requestedAmount`.
**Why:** opportunity cards show a crowdfunding-style progress bar with collected/remaining.
An earlier handler overwrote `collectedAmount` and force-advanced to `donated` on any
donation — fine when all published seeds started at 0, but it silently corrupted totals
and made partially funded cases vanish from `/requests/published` after one donation.
**How to apply:** keep at least one seed case nearly fully funded so the closed loop is
trivially demoable with a single preset donation. Frontend (`donate.tsx`) must also
validate finite/positive amounts and clamp to remaining before submitting.