order detail + types + components

This commit is contained in:
hamid zarghami
2026-01-31 11:00:24 +03:30
parent 7df6d04d5f
commit b730f86b1e
11 changed files with 723 additions and 6 deletions
+30 -1
View File
@@ -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),
});
};