73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
import axios from "@/config/axios";
|
|
import type {
|
|
AddTicketType,
|
|
CreateFinalOrderType,
|
|
OrderDetailResponseType,
|
|
OrderItemResponseType,
|
|
OrderResponseType,
|
|
TicketsResponseType,
|
|
} from "../types/Types";
|
|
import type {
|
|
FieldResponseType,
|
|
ProductResponeType,
|
|
} from "@/pages/product/types/Types";
|
|
|
|
export const getOrders = async () => {
|
|
const { data } = await axios.get<OrderResponseType>(`/admin/orders`);
|
|
return data;
|
|
};
|
|
|
|
export const getOrderDetail = async (id: string) => {
|
|
const { data } = await axios.get<OrderDetailResponseType>(
|
|
`/admin/orders/${id}`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const getTickets = async (orderId: string) => {
|
|
const { data } = await axios.get<TicketsResponseType>(
|
|
`/admin/ticket/order/${orderId}`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const addTicket = async (ticketId: string, params: AddTicketType) => {
|
|
const { data } = await axios.post(
|
|
`/admin/ticket/order/item/${ticketId}`,
|
|
params
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const submitOrder = async (params: CreateFinalOrderType) => {
|
|
const { data } = await axios.post(`/admin/orders`, params);
|
|
return data;
|
|
};
|
|
|
|
export const updateOrder = async (
|
|
orderId: string,
|
|
params: CreateFinalOrderType
|
|
) => {
|
|
const { data } = await axios.patch(`/admin/orders/${orderId}`, params);
|
|
return data;
|
|
};
|
|
|
|
export const getProducts = async () => {
|
|
const { data } = await axios.get<ProductResponeType>(`/admin/products`);
|
|
return data;
|
|
};
|
|
|
|
export const getAttributes = async (productId?: number) => {
|
|
const { data } = await axios.get<FieldResponseType>(
|
|
`/admin/entity/${productId}/field`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const getOrderItem = async (itemId?: number) => {
|
|
const { data } = await axios.get<OrderItemResponseType>(
|
|
`/admin/orders/item/${itemId}`
|
|
);
|
|
return data;
|
|
};
|