92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import axios from "../../../config/axios";
|
|
import {
|
|
AddMessageTicketType,
|
|
CreateCategoryType,
|
|
CreateTicketAdminType,
|
|
CreateTicketMasterType,
|
|
} from "../types/TicketTypes";
|
|
|
|
export const getTickets = async (
|
|
status: string,
|
|
customerId?: string,
|
|
page?: number
|
|
) => {
|
|
const params = new URLSearchParams();
|
|
if (status) params.append("status", status);
|
|
if (customerId) params.append("userId", customerId);
|
|
if (page) params.append("page", page.toString());
|
|
const query = params.toString();
|
|
const { data } = await axios.get(`/tickets/admin?${query}`);
|
|
return data;
|
|
};
|
|
|
|
export const getMessages = async (id: string) => {
|
|
const { data } = await axios.get(`/tickets/${id}/messages`);
|
|
return data;
|
|
};
|
|
|
|
export const addMessageTicket = async (
|
|
id: string,
|
|
params: AddMessageTicketType
|
|
) => {
|
|
const { data } = await axios.post(`/tickets/${id}/messages`, params);
|
|
return data;
|
|
};
|
|
|
|
export const closeTicket = async (id: string) => {
|
|
const { data } = await axios.post(`/tickets/${id}/close`);
|
|
return data;
|
|
};
|
|
|
|
export const createCategory = async (params: CreateCategoryType) => {
|
|
const { data } = await axios.post(`/tickets/category`, params);
|
|
return data;
|
|
};
|
|
|
|
export const getCategories = async () => {
|
|
const { data } = await axios.get(`/tickets/categories`);
|
|
return data;
|
|
};
|
|
|
|
export const referTicket = async (id: string, userId: string) => {
|
|
const { data } = await axios.post(`/tickets/${id}/refer`, {
|
|
adminId: userId,
|
|
});
|
|
return data;
|
|
};
|
|
|
|
export const openTicket = async (id: string) => {
|
|
const { data } = await axios.post(`/tickets/${id}/open`);
|
|
return data;
|
|
};
|
|
|
|
export const createTicket = async (params: CreateTicketAdminType) => {
|
|
const { data } = await axios.post(`/tickets/admin`, params);
|
|
return data;
|
|
};
|
|
|
|
export const getMasters = async () => {
|
|
const { data } = await axios.get(`/tickets/masters`);
|
|
return data;
|
|
};
|
|
|
|
export const getMasterById = async (id: string) => {
|
|
const { data } = await axios.get(`/tickets/masters/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const createMaster = async (params: CreateTicketMasterType) => {
|
|
const { data } = await axios.post(`/tickets/masters`, params);
|
|
return data;
|
|
};
|
|
|
|
export const updateMaster = async (id: string, params: CreateTicketMasterType) => {
|
|
const { data } = await axios.patch(`/tickets/masters/${id}`, params);
|
|
return data;
|
|
};
|
|
|
|
export const deleteMaster = async (id: string) => {
|
|
const { data } = await axios.delete(`/tickets/masters/${id}`);
|
|
return data;
|
|
};
|