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).
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
"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),
|
|
});
|
|
}
|