diff --git a/src/app/admin/clients/[id]/page.tsx b/src/app/admin/clients/[id]/page.tsx
index 95badfa..97b9aa2 100644
--- a/src/app/admin/clients/[id]/page.tsx
+++ b/src/app/admin/clients/[id]/page.tsx
@@ -1,5 +1,5 @@
import { notFound } from "next/navigation";
-import { getClientWithProjects } from "@/lib/admin-queries";
+import { getClientWithProjects, getClientActiveOffers } from "@/lib/admin-queries";
import { ClientActions } from "@/components/admin/ClientActions";
import Link from "next/link";
@@ -11,7 +11,10 @@ export default async function ClientDetailPage({
params: Promise<{ id: string }>;
}) {
const { id } = await params;
- const data = await getClientWithProjects(id);
+ const [data, activeOffers] = await Promise.all([
+ getClientWithProjects(id),
+ getClientActiveOffers(id),
+ ]);
if (!data) notFound();
const { projects, ...client } = data;
@@ -105,6 +108,29 @@ export default async function ClientDetailPage({
)}
+
+ {activeOffers.length > 0 && (
+
+
+ Offerte Attive ({activeOffers.length})
+
+
+ {activeOffers.map((offer) => (
+
+
+
{offer.public_name}
+
{offer.project_name}
+
+ {offer.accepted_total && (
+
+ €{parseFloat(offer.accepted_total).toLocaleString("it-IT", { minimumFractionDigits: 2 })}
+
+ )}
+
+ ))}
+
+
+ )}
);
}
\ No newline at end of file
diff --git a/src/lib/admin-queries.ts b/src/lib/admin-queries.ts
index 9e697fd..5cfab24 100644
--- a/src/lib/admin-queries.ts
+++ b/src/lib/admin-queries.ts
@@ -641,4 +641,47 @@ export async function getClientWithProjects(clientId: string): Promise {
+ const projectRows = await db
+ .select({ id: projects.id, name: projects.name })
+ .from(projects)
+ .where(eq(projects.client_id, clientId));
+
+ if (projectRows.length === 0) return [];
+
+ const projectIds = projectRows.map((p) => p.id);
+ const projectNameMap = new Map(projectRows.map((p) => [p.id, p.name]));
+
+ // Explicit column selection — public_name only, NEVER internal_name
+ const rows = await db
+ .select({
+ offer_id: project_offers.id,
+ project_id: project_offers.project_id,
+ public_name: offer_micros.public_name,
+ accepted_total: project_offers.accepted_total,
+ })
+ .from(project_offers)
+ .innerJoin(offer_micros, eq(project_offers.micro_id, offer_micros.id))
+ .where(inArray(project_offers.project_id, projectIds))
+ .orderBy(asc(project_offers.created_at));
+
+ return rows.map((r) => ({
+ offer_id: r.offer_id,
+ project_id: r.project_id,
+ project_name: projectNameMap.get(r.project_id) ?? "—",
+ public_name: r.public_name,
+ accepted_total: r.accepted_total ? String(r.accepted_total) : null,
+ }));
}
\ No newline at end of file