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,61 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { api } from "@/lib/api-client";
|
||||
import type {
|
||||
NotificationDestinationCreatePayload,
|
||||
NotificationDestinationUpdatePayload,
|
||||
} from "@/lib/types";
|
||||
|
||||
export function useNotificationDestinations() {
|
||||
return useQuery({
|
||||
queryKey: ["notification-destinations"],
|
||||
queryFn: api.listNotificationDestinations,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateNotificationDestination() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (payload: NotificationDestinationCreatePayload) =>
|
||||
api.createNotificationDestination(payload),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["notification-destinations"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateNotificationDestination() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
destinationId,
|
||||
payload,
|
||||
}: {
|
||||
destinationId: string;
|
||||
payload: NotificationDestinationUpdatePayload;
|
||||
}) => api.updateNotificationDestination(destinationId, payload),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["notification-destinations"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteNotificationDestination() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (destinationId: string) => api.deleteNotificationDestination(destinationId),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["notification-destinations"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUnlinkNotificationDestinationCompany() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ destinationId, companyId }: { destinationId: string; companyId: string }) =>
|
||||
api.unlinkNotificationDestinationCompany(destinationId, companyId),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["notification-destinations"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useTestNotificationDestination() {
|
||||
return useMutation({
|
||||
mutationFn: (destinationId: string) => api.testNotificationDestination(destinationId),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user