- /api/cron/reminders: processes pending reminders every 15min, sends WhatsApp with email fallback - /api/cron/overdue: marks overdue pledges daily (7d deferred, 14d immediate) - /api/pledges: GET handler with filtering, search, pagination, sort by dueDate - Dashboard overview: stats, collection progress bar, needs attention, upcoming payments - Dashboard pledges: proper table with status tabs, search, actions, pagination - New shadcn components: Table, Tabs, DropdownMenu, Progress - Setup wizard: 4-step onboarding (org → bank → event → QR code) - Settings API: PUT handler for org create/update - Org resolver: single-tenant fallback to first org - Cron jobs installed: reminders every 15min, overdue check at 6am - Auto-generates installment dates when not provided - HOSTNAME=0.0.0.0 in compose for multi-network binding
111 lines
4.8 KiB
TypeScript
111 lines
4.8 KiB
TypeScript
"use client"
|
|
|
|
import Link from "next/link"
|
|
import { usePathname } from "next/navigation"
|
|
import { LayoutDashboard, Calendar, FileBarChart, Upload, Download, Settings, Plus, ExternalLink } from "lucide-react"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
const navItems = [
|
|
{ href: "/dashboard", label: "Overview", icon: LayoutDashboard },
|
|
{ href: "/dashboard/events", label: "Events", icon: Calendar },
|
|
{ href: "/dashboard/pledges", label: "Pledges", icon: FileBarChart },
|
|
{ href: "/dashboard/reconcile", label: "Reconcile", icon: Upload },
|
|
{ href: "/dashboard/exports", label: "Exports", icon: Download },
|
|
{ href: "/dashboard/settings", label: "Settings", icon: Settings },
|
|
]
|
|
|
|
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
|
const pathname = usePathname()
|
|
|
|
return (
|
|
<div className="min-h-screen bg-gray-50/50">
|
|
{/* Top bar */}
|
|
<header className="sticky top-0 z-40 border-b bg-white/80 backdrop-blur-xl">
|
|
<div className="flex h-14 items-center gap-4 px-4 md:px-6">
|
|
<Link href="/dashboard" className="flex items-center gap-2.5">
|
|
<div className="h-8 w-8 rounded-xl bg-gradient-to-br from-trust-blue to-blue-600 flex items-center justify-center shadow-lg shadow-trust-blue/20">
|
|
<span className="text-white font-bold text-sm">P</span>
|
|
</div>
|
|
<div className="hidden sm:block">
|
|
<span className="font-black text-sm text-gray-900">PNPL</span>
|
|
<span className="text-[10px] text-muted-foreground ml-1">Dashboard</span>
|
|
</div>
|
|
</Link>
|
|
<div className="flex-1" />
|
|
<Link href="/dashboard/events" className="hidden md:block">
|
|
<button className="inline-flex items-center gap-1.5 rounded-lg bg-trust-blue px-3 py-1.5 text-xs font-semibold text-white hover:bg-trust-blue/90 transition-colors">
|
|
<Plus className="h-3 w-3" /> New Event
|
|
</button>
|
|
</Link>
|
|
<Link href="/" className="text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1">
|
|
<ExternalLink className="h-3 w-3" /> <span className="hidden sm:inline">Public Site</span>
|
|
</Link>
|
|
</div>
|
|
</header>
|
|
|
|
<div className="flex">
|
|
{/* Desktop sidebar */}
|
|
<aside className="hidden md:flex w-56 flex-col border-r bg-white min-h-[calc(100vh-3.5rem)] py-3 px-2">
|
|
<nav className="space-y-0.5">
|
|
{navItems.map((item) => {
|
|
const isActive = pathname === item.href || (item.href !== "/dashboard" && pathname.startsWith(item.href))
|
|
return (
|
|
<Link
|
|
key={item.href}
|
|
href={item.href}
|
|
className={cn(
|
|
"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",
|
|
isActive
|
|
? "bg-trust-blue/5 text-trust-blue"
|
|
: "text-muted-foreground hover:bg-gray-100 hover:text-foreground"
|
|
)}
|
|
>
|
|
<item.icon className="h-4 w-4" />
|
|
{item.label}
|
|
</Link>
|
|
)
|
|
})}
|
|
</nav>
|
|
|
|
<div className="mt-auto px-2 pt-4">
|
|
<div className="rounded-xl bg-gradient-to-br from-trust-blue/5 to-warm-amber/5 border p-3 space-y-1.5">
|
|
<p className="text-xs font-semibold">Need help?</p>
|
|
<p className="text-[10px] text-muted-foreground leading-relaxed">
|
|
Get a fractional Head of Technology to optimise your charity's digital stack.
|
|
</p>
|
|
<Link href="/dashboard/apply" className="inline-block text-[10px] font-semibold text-trust-blue hover:underline">
|
|
Learn more →
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
|
|
{/* Mobile bottom nav */}
|
|
<nav className="md:hidden fixed bottom-0 left-0 right-0 z-40 border-t bg-white/95 backdrop-blur-xl flex justify-around py-1.5 px-1">
|
|
{navItems.slice(0, 5).map((item) => {
|
|
const isActive = pathname === item.href || (item.href !== "/dashboard" && pathname.startsWith(item.href))
|
|
return (
|
|
<Link
|
|
key={item.href}
|
|
href={item.href}
|
|
className={cn(
|
|
"flex flex-col items-center gap-0.5 py-1 px-2 rounded-lg transition-colors",
|
|
isActive ? "text-trust-blue" : "text-muted-foreground"
|
|
)}
|
|
>
|
|
<item.icon className="h-5 w-5" />
|
|
<span className="text-[9px] font-medium">{item.label}</span>
|
|
</Link>
|
|
)
|
|
})}
|
|
</nav>
|
|
|
|
{/* Main content */}
|
|
<main className="flex-1 p-4 md:p-6 pb-20 md:pb-6 max-w-6xl">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|