From b2260fe8397040ccc234751bedf9c6fbf8c1876f Mon Sep 17 00:00:00 2001 From: valentinbvro Date: Tue, 28 Jul 2026 22:34:49 +0200 Subject: [PATCH] feat: AI draft pentru research brief + sinteza AI in briefing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BriefForm: buton "Generează cu AI" cheama /v1/research-briefs/draft si precompleteaza titlul+rezumatul; textul spune explicit ca nimic nu s-a salvat inca si arata costul real al generarii - Briefing: afiseaza aiExplanation cand exista, cu nota ca prioritizarea ramane deterministica si AI-ul doar explica --- src/app/dashboard/companies/brief-form.tsx | 52 +++++++++++++++++++--- src/app/dashboard/page.tsx | 10 ++++- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/app/dashboard/companies/brief-form.tsx b/src/app/dashboard/companies/brief-form.tsx index 8edc6fe..2c121e2 100644 --- a/src/app/dashboard/companies/brief-form.tsx +++ b/src/app/dashboard/companies/brief-form.tsx @@ -19,17 +19,37 @@ interface BriefFormProps { onClose: () => void; } +interface DraftResponse { + title: string; + summary: string; + costUsd: number; +} + export function BriefForm({ tenantId, organizationId, organizationName, onClose }: BriefFormProps) { const queryClient = useQueryClient(); const { register, handleSubmit, + setValue, formState: { errors, isSubmitting }, } = useForm({ resolver: zodResolver(briefSchema), defaultValues: { title: `Research brief — ${organizationName}` }, }); + const generateDraft = useMutation({ + mutationFn: () => + apiFetch('/v1/research-briefs/draft', { + method: 'POST', + tenantId, + body: { organizationId }, + }), + onSuccess: (draft) => { + setValue('title', draft.title, { shouldValidate: true }); + setValue('summary', draft.summary, { shouldValidate: true }); + }, + }); + const createBrief = useMutation({ mutationFn: (values: BriefForm) => apiFetch('/v1/research-briefs', { @@ -58,14 +78,32 @@ export function BriefForm({ tenantId, organizationId, organizationName, onClose {errors.title &&

{errors.title.message}

}
- -