From 60e5befa3173f325a41d2b0c5d582819e4f2a807 Mon Sep 17 00:00:00 2001 From: valentinbvro Date: Tue, 28 Jul 2026 22:01:36 +0200 Subject: [PATCH] feat: Faza A2 -- cautare companii, segmente salvate, research briefs - pagina Companii: cautare Apollo prin ceo-api, salveaza cautarea ca segment, creeaza research brief per rezultat - pagina Segmente: reruleaza o cautare salvata, sterge - pagina Research: listeaza briefs cu surse (linkuri catre Apollo/altele) - Overview devine un briefing determinist (restante/urmatoarele 7 zile + activitate saptamanala), cu explicatia AI marcata explicit ca neconstruita in loc de ascunsa --- src/app/dashboard/companies/brief-form.tsx | 89 ++++++++++++++ src/app/dashboard/companies/page.tsx | 131 +++++++++++++++++++++ src/app/dashboard/page.tsx | 97 ++++++++++++--- src/app/dashboard/research/page.tsx | 75 ++++++++++++ src/app/dashboard/segments/page.tsx | 94 +++++++++++++++ src/components/dashboard-shell.tsx | 7 +- src/lib/api.ts | 51 ++++++++ 7 files changed, 524 insertions(+), 20 deletions(-) create mode 100644 src/app/dashboard/companies/brief-form.tsx create mode 100644 src/app/dashboard/companies/page.tsx create mode 100644 src/app/dashboard/research/page.tsx create mode 100644 src/app/dashboard/segments/page.tsx diff --git a/src/app/dashboard/companies/brief-form.tsx b/src/app/dashboard/companies/brief-form.tsx new file mode 100644 index 0000000..8edc6fe --- /dev/null +++ b/src/app/dashboard/companies/brief-form.tsx @@ -0,0 +1,89 @@ +'use client'; + +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod'; +import { apiFetch } from '../../../lib/api'; + +const briefSchema = z.object({ + title: z.string().min(1, 'Titlul este obligatoriu').max(250), + summary: z.string().min(1, 'Rezumatul este obligatoriu').max(5000), +}); +type BriefForm = z.infer; + +interface BriefFormProps { + tenantId: string; + organizationId: string; + organizationName: string; + onClose: () => void; +} + +export function BriefForm({ tenantId, organizationId, organizationName, onClose }: BriefFormProps) { + const queryClient = useQueryClient(); + const { + register, + handleSubmit, + formState: { errors, isSubmitting }, + } = useForm({ + resolver: zodResolver(briefSchema), + defaultValues: { title: `Research brief — ${organizationName}` }, + }); + + const createBrief = useMutation({ + mutationFn: (values: BriefForm) => + apiFetch('/v1/research-briefs', { + method: 'POST', + tenantId, + body: { organizationId, organizationName, ...values }, + }), + onSuccess: async () => { + await queryClient.invalidateQueries({ queryKey: ['research-briefs', tenantId] }); + onClose(); + }, + }); + + return ( +
+
+

Research brief

+

{organizationName}

+ +
createBrief.mutate(values))} noValidate className="space-y-4"> +
+ + + {errors.title &&

{errors.title.message}

} +
+
+ +