Complete EHSAN POC: fix all code review findings

- API routes: explicit return types on all Express handlers (fixes TS7030),
  `beneficiaryName` now accepted and stored in /thank-you route per OpenAPI spec.

- Home page: added search bar (filters by case ID, description, name) +
  Featured Opportunities section with live cards, progress bars, and Donate buttons.

- Opportunities page: added need-type filter pill bar (all 8 types + "All Types")
  with active state highlighting; empty state respects selected filter.

- i18n: expanded translations with all previously hardcoded strings
  (trackCase, notFound, noData, currentStep, search, searchPlaceholder,
  featuredTitle, noResults, donate.caseSummary, donate.caseNotFound,
  admin.noRequests, admin.needType, admin.amount, admin.track, admin.whatsapp,
  track.caseInfo, track.rejected, track.currentStepLabel, track.submitThankYou,
  thankYou.successNote, thankYou.beneficiaryMessageLabel,
  whatsapp.donorPhone, whatsapp.beneficiaryMessage, whatsapp.noEntries,
  opportunities.noOpportunities, opportunities.verified).
  All pages now use t.* — zero hardcoded English UI strings.

- TypeScript: both frontend (tsc --noEmit) and API server build are clean.
This commit is contained in:
Replit Agent
2026-06-05 17:12:44 +00:00
parent 12111a9562
commit 1dcfa0bfa5
9 changed files with 640 additions and 258 deletions
+36 -16
View File
@@ -4,8 +4,10 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
import { useParams, useLocation } from "wouter";
import { useLanguage } from "../contexts/LanguageContext";
import { useGetRequest, useSubmitThankYou, getListRequestsQueryKey, getGetRequestQueryKey } from "@workspace/api-client-react";
import {
useGetRequest, useSubmitThankYou,
getListRequestsQueryKey, getGetRequestQueryKey,
} from "@workspace/api-client-react";
import { useQueryClient } from "@tanstack/react-query";
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
import { Input } from "@/components/ui/input";
@@ -14,6 +16,7 @@ import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { CheckCircle, Heart } from "lucide-react";
import { Skeleton } from "@/components/ui/skeleton";
import { Link } from "wouter";
const schema = z.object({
beneficiaryName: z.string().min(2),
@@ -38,11 +41,14 @@ export default function ThankYou() {
const form = useForm<FormData>({
resolver: zodResolver(schema),
defaultValues: {
beneficiaryName: request?.beneficiaryName || "",
beneficiaryName: "",
message: "",
},
});
// Pre-fill name once loaded
const beneficiaryName = request?.beneficiaryName || "";
const onSubmit = (data: FormData) => {
submitThankYou.mutate(
{
@@ -68,6 +74,14 @@ export default function ThankYou() {
);
}
if (!request) {
return (
<div className="container mx-auto px-4 py-12 text-center text-muted-foreground">
{t.common.notFound}
</div>
);
}
if (submitted) {
return (
<div className="container mx-auto px-4 py-12 max-w-xl">
@@ -78,15 +92,15 @@ export default function ThankYou() {
<CheckCircle className="w-12 h-12 text-green-500" />
</div>
<h2 className="text-2xl font-bold text-green-700 mb-2">{t.common.success}</h2>
<p className="text-muted-foreground">
{t.thankYou.title}
</p>
<p className="mt-4 text-sm text-muted-foreground">
Your thank-you message will be sent to the donor via WhatsApp through OpenClaw.
</p>
<p className="text-muted-foreground">{t.thankYou.title}</p>
<p className="mt-4 text-sm text-muted-foreground">{t.thankYou.successNote}</p>
<div className="mt-8 flex gap-3 justify-center">
<Button onClick={() => setLocation(`/track/${params.id}`)}>Track Case</Button>
<Button variant="outline" onClick={() => setLocation("/")}>Home</Button>
<Button onClick={() => setLocation(`/track/${params.id}`)}>
{t.common.trackCase}
</Button>
<Button variant="outline" onClick={() => setLocation("/")}>
{t.common.home}
</Button>
</div>
</CardContent>
</Card>
@@ -98,9 +112,9 @@ export default function ThankYou() {
<div className="container mx-auto px-4 py-12 max-w-xl">
<div className="mb-8">
<h1 className="text-3xl font-bold text-foreground">{t.thankYou.title}</h1>
{request && (
<p className="text-muted-foreground mt-1">{request.caseId} {request.beneficiaryName}</p>
)}
<p className="text-muted-foreground mt-1">
{request.caseId} {request.beneficiaryName}
</p>
</div>
<Card>
@@ -119,8 +133,9 @@ export default function ThankYou() {
<FormControl>
<Input
data-testid="input-beneficiaryName"
defaultValue={request?.beneficiaryName || ""}
placeholder={beneficiaryName}
{...field}
defaultValue={beneficiaryName}
/>
</FormControl>
<FormMessage />
@@ -137,7 +152,6 @@ export default function ThankYou() {
<Textarea
data-testid="input-thankYouMessage"
rows={5}
placeholder="جزاكم الله خيراً، وصلني الدعم وكان له أثر كبير عليّ."
{...field}
/>
</FormControl>
@@ -157,6 +171,12 @@ export default function ThankYou() {
</Form>
</CardContent>
</Card>
<div className="mt-4 text-center">
<Link href={`/track/${params.id}`}>
<Button variant="ghost" size="sm">{t.common.back}</Button>
</Link>
</div>
</div>
);
}