first commit
This commit is contained in:
20
services/hooks/ticket.hook.ts
Normal file
20
services/hooks/ticket.hook.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { getAllTickets, getAllTicketsExport, removeTicket } from "../api/ticket.api";
|
||||
|
||||
export const useGetAllTickets = (params: {
|
||||
page: number;
|
||||
departmentId?: string;
|
||||
priority?: string;
|
||||
status?: string;
|
||||
}) => {
|
||||
return useQuery({
|
||||
// قرار دادن پارامترها در queryKey باعث میشود با تغییر هر کدام، کش باطل و درخواست جدید ارسال شود
|
||||
queryKey: ["get-all-tickets", params],
|
||||
queryFn: () => getAllTickets(params),
|
||||
retry: false,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
};
|
||||
|
||||
export const useRemoveTicket = () => useMutation({mutationFn:removeTicket})
|
||||
export const useGetAllTicketsExport = () => useMutation({mutationFn:getAllTicketsExport})
|
||||
Reference in New Issue
Block a user