20 lines
533 B
TypeScript
20 lines
533 B
TypeScript
import * as api from "../service/NotificationService";
|
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
|
export const useGetNotifications = () => {
|
|
return useQuery({
|
|
queryKey: ["notifications"],
|
|
queryFn: api.getNotifications,
|
|
});
|
|
};
|
|
|
|
export const useDeleteNotification = () => {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: api.deleteNotification,
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ["notifications"] });
|
|
},
|
|
});
|
|
};
|