# Generate payment feature pages + App Router routes from pathlib import Path ROOT = Path(r"F:/TorbatYar/frontend") MOD = ROOT / "modules" / "payment" / "features" APP = ROOT / "app" / "payment" # Feature implementations - compact but real API wired FEATURES = {} FEATURES["hub"] = r'''"use client"; import Link from "next/link"; import { CreditCard, LayoutDashboard, Wallet, Plug, Building2, Activity } from "lucide-react"; import { usePaymentCapabilities, usePaymentHealth } from "@/modules/payment/hooks/usePaymentCapabilities"; import { PaymentPageError, PaymentPageLoader } from "@/modules/payment/pages/shared"; const LINKS = [ { href: "/payment/dashboard", label: "داشبورد اجرایی", icon: LayoutDashboard }, { href: "/payment/requests", label: "درخواستهای پرداخت", icon: Wallet }, { href: "/payment/psp", label: "مدیریت درگاه", icon: Plug }, { href: "/payment/merchants", label: "پذیرندگان", icon: Building2 }, { href: "/payment/monitoring", label: "مانیتورینگ", icon: Activity }, ]; export function PaymentHub() { const health = usePaymentHealth(); const caps = usePaymentCapabilities(); if (health.isLoading) return ; if (health.isError) return health.refetch()} />; return ( تربتپی پلتفرم پرداخت سازمانی — MVP تا فاز ۱۴.۵ وضعیت سرویس: {health.data?.status} نسخه: {health.data?.version} فاز: {caps.data?.phase ?? "—"} باندلها: {(caps.data?.active_bundles ?? []).join(", ") || "هیچ"} {LINKS.map((l) => { const Icon = l.icon; return ( {l.label} ); })} ); } ''' FEATURES["dashboard"] = r'''"use client"; import { useMemo } from "react"; import { useQueries } from "@tanstack/react-query"; import { useTenantId } from "@/hooks/useTenantId"; import { paymentApi } from "@/modules/payment/services/payment-api"; import { PaymentBarChart, PaymentDonutChart, PaymentStatCards } from "@/modules/payment/components/PaymentCharts"; import { PaymentPageError, PaymentPageLoader } from "@/modules/payment/pages/shared"; import { usePaymentCapabilities } from "@/modules/payment/hooks/usePaymentCapabilities"; export function PaymentDashboard() { const { tenantId } = useTenantId(); const caps = usePaymentCapabilities(); const [tx, req, audit] = useQueries({ queries: [ { queryKey: ["payment", tenantId, "tx"], queryFn: () => paymentApi.transactions.list(tenantId!), enabled: !!tenantId }, { queryKey: ["payment", tenantId, "req"], queryFn: () => paymentApi.requests.list(tenantId!), enabled: !!tenantId }, { queryKey: ["payment", tenantId, "audit"], queryFn: () => paymentApi.audit.list(tenantId!), enabled: !!tenantId }, ], }); const loading = !tenantId || tx.isLoading || req.isLoading; const err = tx.error || req.error; const stats = useMemo(() => { const requests = req.data ?? []; const txs = tx.data ?? []; const paid = requests.filter((r) => r.status === "paid").length; const failed = requests.filter((r) => r.status === "failed").length; const volume = txs.reduce((s, t) => s + Number(t.amount_minor ?? 0), 0); const statusDist = Object.entries( requests.reduce>((acc, r) => { const k = String(r.status ?? "unknown"); acc[k] = (acc[k] ?? 0) + 1; return acc; }, {}) ).map(([name, value]) => ({ name, value })); return { paid, failed, volume, totalReq: requests.length, totalTx: txs.length, statusDist, recent: (audit.data ?? []).slice(0, 8) }; }, [req.data, tx.data, audit.data]); if (loading) return ; if (err) return { tx.refetch(); req.refetch(); }} />; return ( داشبورد اجرایی تربتپی دادهها از API واقعی تراکنش، درخواست و حسابرسی توزیع وضعیت درخواستها حجم تراکنشها بر اساس ارز >((acc, t) => { const c = String(t.currency ?? "IRR"); acc[c] = (acc[c] ?? 0) + Number(t.amount_minor ?? 0); return acc; }, {}) ).map(([name, value]) => ({ name, value }))} /> فعالیت اخیر (حسابرسی) {stats.recent.length === 0 ? ( فعالیتی ثبت نشده ) : ( stats.recent.map((a, i) => ( {String(a.action)} — {String(a.entity_type)} {a.created_at ? new Date(String(a.created_at)).toLocaleString("fa-IR") : "—"} )) )} ); } ''' # Write generator that creates list-based features and remaining pages print("writing generator body...")
پلتفرم پرداخت سازمانی — MVP تا فاز ۱۴.۵
{l.label}
دادهها از API واقعی تراکنش، درخواست و حسابرسی