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).
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
"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] });
|
|
},
|
|
});
|
|
}
|