You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
952 B
TypeScript

// frontend/lib/hooks/useNotify.ts — 알림 트리아지/가드/다이제스트/발신자 SWR 훅
"use client";
import useSWR from "swr";
import type { Digest, NotifyGuard, SenderRule, Triage } from "@/lib/types";
import { notifyApi } from "@/lib/notify/api";
export function useNotify() {
const {
data: triage,
error,
mutate,
} = useSWR<Triage>("notifications", () => notifyApi.triage(), { revalidateOnFocus: false });
const { data: guard, mutate: mGuard } = useSWR<NotifyGuard>(
"notifications/guard",
() => notifyApi.guard(),
{ revalidateOnFocus: false },
);
const { data: digests } = useSWR<Digest[]>("notifications/digests", () => notifyApi.digests(), {
revalidateOnFocus: false,
});
const { data: senders } = useSWR<SenderRule[]>(
"notifications/senders",
() => notifyApi.senders(),
{ revalidateOnFocus: false },
);
return { triage, guard, digests, senders, error, mutate, mGuard };
}