added shipping method
This commit is contained in:
@@ -5,15 +5,14 @@ import {
|
||||
UseQueryOptions,
|
||||
} from "@tanstack/react-query";
|
||||
import { apiClient } from "@/lib/api";
|
||||
import type { CartItem } from "@/lib/types/api";
|
||||
import type {
|
||||
CartItem,
|
||||
CartResponse,
|
||||
CreateOrderPayload,
|
||||
OrderDelivery,
|
||||
} from "@/lib/types/api";
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface CartResponse {
|
||||
message: string;
|
||||
data: CartItem[];
|
||||
errorDetails?: string;
|
||||
}
|
||||
|
||||
const pendingUpdates = new Map<number, number>();
|
||||
let updateLock = false;
|
||||
|
||||
@@ -457,21 +456,24 @@ export function useUpdateCartItemQuantity() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useOrderDeliveries() {
|
||||
return useQuery({
|
||||
queryKey: ["order-deliveries"],
|
||||
queryFn: async () => {
|
||||
const response = await apiClient.get<{
|
||||
message: string;
|
||||
data: OrderDelivery[];
|
||||
}>("/order-deliveries");
|
||||
return response.data.data;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateOrder() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: {
|
||||
customer_name?: string;
|
||||
customer_phone: number;
|
||||
customer_address: string;
|
||||
shipping_method: string;
|
||||
payment_type_id: number;
|
||||
delivery_time?: string;
|
||||
delivery_at?: string;
|
||||
region: string;
|
||||
notes?: string;
|
||||
}) => {
|
||||
mutationFn: async (payload: CreateOrderPayload) => {
|
||||
const response = await apiClient.post("/orders", payload);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user