Initial commit: CI Agent competitive-intelligence monitoring app
FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { api } from "@/lib/api-client";
|
||||
|
||||
export function useCompanyReports(companyId: string) {
|
||||
return useQuery({ queryKey: ["reports", companyId], queryFn: () => api.listReports(companyId) });
|
||||
}
|
||||
|
||||
export function useReport(reportId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ["report", reportId],
|
||||
queryFn: () => api.getReport(reportId as string),
|
||||
enabled: Boolean(reportId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useReportMarkdown(reportId: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ["report", reportId, "markdown"],
|
||||
queryFn: () => api.getReportMarkdown(reportId as string),
|
||||
enabled: Boolean(reportId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useGenerateReport(companyId: string) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: () => api.generateReport(companyId),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["reports", companyId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["companies", companyId] });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user