first commit
This commit is contained in:
12
services/hooks/department.hook.ts
Normal file
12
services/hooks/department.hook.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getDepartments } from "../api/department.api";
|
||||
|
||||
export const useGetAllDepartments = () => {
|
||||
return useQuery({
|
||||
// قرار دادن پارامترها در queryKey باعث میشود با تغییر هر کدام، کش باطل و درخواست جدید ارسال شود
|
||||
queryKey: ['get-all-tickets'],
|
||||
queryFn: () => getDepartments(),
|
||||
retry: false,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
};
|
||||
30
services/hooks/report.hook.ts
Normal file
30
services/hooks/report.hook.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import * as api from "../api/report.api";
|
||||
|
||||
// هوکهای Mutation برای دریافت گزارشها به صورت دستی (On-Demand)
|
||||
|
||||
export const useMutateStatsReport = () => useMutation({ mutationFn: api.getStatsReport });
|
||||
|
||||
export const useMutateDepartmentReport = () => useMutation({ mutationFn: api.getDepartmentReport });
|
||||
|
||||
export const useMutateAgentPerformance = () => useMutation({ mutationFn: api.getAgentPerformance });
|
||||
|
||||
export const useMutateAvgResolutionTime = () => useMutation({ mutationFn: api.getAvgResolutionTime });
|
||||
|
||||
export const useMutateCriticalTickets = () => useMutation({ mutationFn: api.getCriticalTickets });
|
||||
|
||||
export const useMutateTicketsTrend = () => useMutation({ mutationFn: (params: any) => api.getTicketsTrend(params) });
|
||||
|
||||
export const useMutateClosureRate = () => useMutation({ mutationFn: api.getClosureRate });
|
||||
|
||||
export const useMutateSlaBreach = () => useMutation({ mutationFn: api.getSlaBreach });
|
||||
|
||||
export const useMutateAgingReport = () => useMutation({ mutationFn: api.getAgingReport });
|
||||
|
||||
export const useMutateAgentEfficiency = () => useMutation({ mutationFn: api.getAgentEfficiency });
|
||||
|
||||
export const useMutateDepartmentLoad = () => useMutation({ mutationFn: api.getDepartmentLoad });
|
||||
|
||||
export const useMutateKpiReport = () => useMutation({ mutationFn: api.getKpiReport });
|
||||
|
||||
export const useMutatePredictionReport = () => useMutation({ mutationFn: api.getPredictionReport });
|
||||
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})
|
||||
8
services/hooks/users.hook.ts
Normal file
8
services/hooks/users.hook.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getUsers } from "../api/users.api";
|
||||
|
||||
export const useGetAllUsers = () =>
|
||||
useQuery({
|
||||
queryKey: ["get-all-users"],
|
||||
queryFn: getUsers,
|
||||
});
|
||||
Reference in New Issue
Block a user