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,42 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { api } from "@/lib/api-client";
|
||||
import type { SourceCreatePayload, SourceUpdatePayload } from "@/lib/types";
|
||||
|
||||
export function useSources(companyId: string) {
|
||||
return useQuery({ queryKey: ["sources", companyId], queryFn: () => api.listSources(companyId) });
|
||||
}
|
||||
|
||||
export function useCreateSource(companyId: string) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (payload: SourceCreatePayload) => api.createSource(companyId, payload),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["sources", companyId] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateSource(companyId: string) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ sourceId, payload }: { sourceId: string; payload: SourceUpdatePayload }) =>
|
||||
api.updateSource(sourceId, payload),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["sources", companyId] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteSource(companyId: string) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (sourceId: string) => api.deleteSource(sourceId),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["sources", companyId] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useTestSource(companyId: string) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (sourceId: string) => api.testSource(sourceId),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["sources", companyId] }),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user