feat(06-01): move client list to /admin/clients, /admin redirects to clients
- New /admin/clients/page.tsx contains full client list with getAllClientsWithPayments - Toggle archived link updated from /admin?archived=1 to /admin/clients?archived=1 - /admin/page.tsx replaced with redirect() to /admin/clients
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import Link from "next/link";
|
||||
import { getAllClientsWithPayments } from "@/lib/admin-queries";
|
||||
import { ClientRow } from "@/components/admin/ClientRow";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export const revalidate = 0;
|
||||
|
||||
export default async function AdminClientsPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ archived?: string }>;
|
||||
}) {
|
||||
const { archived } = await searchParams;
|
||||
const showArchived = archived === "1";
|
||||
const clients = await getAllClientsWithPayments(showArchived);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div className="flex items-center gap-4">
|
||||
<h1 className="text-2xl font-bold text-[#1a1a1a]">Clienti</h1>
|
||||
<a
|
||||
href={showArchived ? "/admin/clients" : "/admin/clients?archived=1"}
|
||||
className="text-xs text-[#71717a] hover:text-[#1A463C] underline underline-offset-2"
|
||||
>
|
||||
{showArchived ? "Nascondi archiviati" : "Mostra archiviati"}
|
||||
</a>
|
||||
</div>
|
||||
<Button asChild>
|
||||
<Link href="/admin/clients/new">+ Nuovo cliente</Link>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{clients.length === 0 ? (
|
||||
<div className="text-center py-20 text-[#71717a]">
|
||||
<p>{showArchived ? "Nessun cliente archiviato." : "Nessun cliente ancora."}</p>
|
||||
{!showArchived && (
|
||||
<p className="mt-2">
|
||||
<Link href="/admin/clients/new" className="text-[#1A463C] hover:underline font-medium">
|
||||
Crea il primo cliente
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-white rounded-lg border border-[#e5e7eb] overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-[#f9f9f9] border-b border-[#e5e7eb]">
|
||||
<tr>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Cliente</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">LTV</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Importo incassato</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Importo da saldare</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{clients.map((client) => (
|
||||
<ClientRow key={client.id} client={client} />
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+4
-65
@@ -1,67 +1,6 @@
|
||||
import Link from "next/link";
|
||||
import { getAllClientsWithPayments } from "@/lib/admin-queries";
|
||||
import { ClientRow } from "@/components/admin/ClientRow";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export const revalidate = 0;
|
||||
|
||||
export default async function AdminDashboard({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ archived?: string }>;
|
||||
}) {
|
||||
const { archived } = await searchParams;
|
||||
const showArchived = archived === "1";
|
||||
const clients = await getAllClientsWithPayments(showArchived);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div className="flex items-center gap-4">
|
||||
<h1 className="text-2xl font-bold text-[#1a1a1a]">Clienti</h1>
|
||||
<a
|
||||
href={showArchived ? "/admin" : "/admin?archived=1"}
|
||||
className="text-xs text-[#71717a] hover:text-[#1A463C] underline underline-offset-2"
|
||||
>
|
||||
{showArchived ? "Nascondi archiviati" : "Mostra archiviati"}
|
||||
</a>
|
||||
</div>
|
||||
<Button asChild>
|
||||
<Link href="/admin/clients/new">+ Nuovo cliente</Link>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{clients.length === 0 ? (
|
||||
<div className="text-center py-20 text-[#71717a]">
|
||||
<p>{showArchived ? "Nessun cliente archiviato." : "Nessun cliente ancora."}</p>
|
||||
{!showArchived && (
|
||||
<p className="mt-2">
|
||||
<Link href="/admin/clients/new" className="text-[#1A463C] hover:underline font-medium">
|
||||
Crea il primo cliente
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-white rounded-lg border border-[#e5e7eb] overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-[#f9f9f9] border-b border-[#e5e7eb]">
|
||||
<tr>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Cliente</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">LTV</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Importo incassato</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Importo da saldare</th>
|
||||
<th className="text-left py-3 px-4 font-medium text-[#71717a]">Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{clients.map((client) => (
|
||||
<ClientRow key={client.id} client={client} />
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
// Dashboard page — content added in Phase 6 Plan 02
|
||||
export default function AdminRoot() {
|
||||
redirect("/admin/clients");
|
||||
}
|
||||
Reference in New Issue
Block a user