order detail + types + components
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import * as api from "../service/OrderService";
|
||||
import type { AddTicketType } from "../types/Types";
|
||||
|
||||
export const useGetOrders = () => {
|
||||
return useQuery({
|
||||
@@ -7,3 +8,31 @@ export const useGetOrders = () => {
|
||||
queryFn: api.getOrders,
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetOrderDetails = (id: string) => {
|
||||
return useQuery({
|
||||
queryKey: ["order", id],
|
||||
queryFn: () => api.getOrderDetail(id),
|
||||
enabled: !!id,
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetTickets = (orderId: string) => {
|
||||
return useQuery({
|
||||
queryKey: ["tickets", orderId],
|
||||
queryFn: () => api.getTickets(orderId),
|
||||
enabled: !!orderId,
|
||||
});
|
||||
};
|
||||
|
||||
export const useAddTicket = () => {
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
orderId,
|
||||
params,
|
||||
}: {
|
||||
orderId: string;
|
||||
params: AddTicketType;
|
||||
}) => api.addTicket(orderId, params),
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user