fdcc938252
- Migration 0010: tabella proposals (id, slug, lead_id, client_id, offer_macro_id, content jsonb, state, selected_tier, accepted_at) applicata a prod via SSH tunnel - @anthropic-ai/sdk@0.105.0 installato; ANTHROPIC_API_KEY in .env.local - src/lib/proposal/: schema Zod ProposalContent, agente Claude Opus 4.8, assemble (AI + offerta DB + config consulente), queries, profile.ts - Admin: /admin/preventivi lista + /genera (pre-fill ?lead_id=X) + /[id] review - Sidebar: voce Preventivi + CTA globale lime "Genera preventivo" - LeadDetail: pulsante "Genera preventivo" → /admin/preventivi/genera?lead_id=X - Pagina pubblica /preventivo/[slug]: deck 20+ slide light-mode iamcavalli, navigazione frecce + dot + keyboard, accept/reject con guard immutabilità - STATE.md aggiornato (80%), 21-PLAN.md scritto nel formato GSD Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { getAllLeads } from "@/lib/lead-service";
|
|
import { getOfferListCards } from "@/lib/offer-queries";
|
|
import { db } from "@/db";
|
|
import { clients } from "@/db/schema";
|
|
import { asc } from "drizzle-orm";
|
|
import { generateProposalDraft } from "../actions";
|
|
import { GeneraProposalForm } from "./GeneraProposalForm";
|
|
|
|
export const revalidate = 0;
|
|
|
|
export default async function GeneraPage({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ lead_id?: string }>;
|
|
}) {
|
|
const { lead_id: preselectedLeadId } = await searchParams;
|
|
|
|
const [leads, offerCards, allClients] = await Promise.all([
|
|
getAllLeads(200),
|
|
getOfferListCards(),
|
|
db.select({ id: clients.id, name: clients.name, brand_name: clients.brand_name })
|
|
.from(clients)
|
|
.orderBy(asc(clients.name)),
|
|
]);
|
|
|
|
const activeOffers = offerCards.filter((o) => !o.is_archived);
|
|
|
|
return (
|
|
<div className="max-w-2xl mx-auto space-y-6">
|
|
<div>
|
|
<h1 className="text-2xl font-semibold text-foreground">Genera preventivo</h1>
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
Scegli il lead o il cliente e l'offerta. L'AI legge i transcript e genera la bozza.
|
|
</p>
|
|
</div>
|
|
<GeneraProposalForm
|
|
leads={leads.map((l) => ({ id: l.id, name: l.name, company: l.company }))}
|
|
clients={allClients}
|
|
offers={activeOffers}
|
|
action={generateProposalDraft}
|
|
preselectedLeadId={preselectedLeadId}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|