first commit

This commit is contained in:
2026-05-23 13:22:10 +03:30
parent 5f9ee72174
commit 6591a52f27
52 changed files with 3937 additions and 133 deletions

6
services/api/auth.api.ts Normal file
View File

@@ -0,0 +1,6 @@
import callAPI from "../caller/config";
export async function loginUser(data: any) {
return await callAPI.post("/auth/login", data).then((res) => res.data);
}

View File

@@ -0,0 +1,5 @@
import callAPI from "../caller/config";
export async function getDepartments() {
return await callAPI.get("/department/all").then((res) => res.data);
}

View File

@@ -0,0 +1,53 @@
import callAPI from "../caller/config";
export async function getStatsReport() {
return await callAPI.get("/report/stats").then((res) => res.data);
}
export async function getDepartmentReport() {
return await callAPI.get("/report/departments").then((res) => res.data);
}
export async function getAgentPerformance() {
return await callAPI.get("/report/agents").then((res) => res.data);
}
export async function getAvgResolutionTime() {
return await callAPI.get("/report/avg-resolution").then((res) => res.data);
}
export async function getCriticalTickets() {
return await callAPI.get("/report/critical").then((res) => res.data);
}
export async function getTicketsTrend(params: any) {
return await callAPI.get("/report/trend", { params }).then((res) => res.data);
}
export async function getClosureRate() {
return await callAPI.get("/report/closure-rate").then((res) => res.data);
}
export async function getSlaBreach() {
return await callAPI.get("/report/sla").then((res) => res.data);
}
export async function getAgingReport() {
return await callAPI.get("/report/aging").then((res) => res.data);
}
export async function getAgentEfficiency() {
return await callAPI.get("/report/agent-efficiency").then((res) => res.data);
}
export async function getDepartmentLoad() {
return await callAPI.get("/report/department-load").then((res) => res.data);
}
export async function getKpiReport() {
return await callAPI.get("/report/kpi").then((res) => res.data);
}
export async function getPredictionReport() {
return await callAPI.get("/report/prediction").then((res) => res.data);
}

View File

@@ -0,0 +1,17 @@
import callAPI from "../caller/config";
export async function createTicket(data: any) {
return await callAPI.post("/ticket/create", data).then((res) => res.data);
}
export async function getAllTickets(params: any) {
return await callAPI.get("/ticket/all", { params }).then((res) => res.data);
}
export async function removeTicket(id: string) {
return await callAPI.delete(`/ticket/remove/${id}`).then((res) => res.data);
}
export async function getAllTicketsExport(params: any) {
return await callAPI.get("/ticket/all/export", { params }).then((res) => res.data);
}

View File

@@ -0,0 +1,5 @@
import callAPI from "../caller/config";
export async function getUsers() {
return await callAPI.get("/user/all").then((res) => res.data);
}

25
services/caller/config.ts Normal file
View File

@@ -0,0 +1,25 @@
import axios from "axios";
const callAPISetting = axios.create({
baseURL: "http://localhost:8000/api/v1",
withCredentials: true,
});
callAPISetting.interceptors.request.use(
(res) => res,
(err) => Promise.reject(err),
);
callAPISetting.interceptors.response.use(
(res) => res,
async (err) => Promise.reject(err),
);
const callAPI = {
post: callAPISetting.post,
get: callAPISetting.get,
put: callAPISetting.put,
delete: callAPISetting.delete,
};
export default callAPI;

View 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,
});
};

View 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 });

View 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})

View 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,
});