import { useInfiniteQuery, useMutation, useQuery } from "@tanstack/react-query"; import { AuthResponseBodyType } from "../type/apiType"; import { OrderCreateRequestType, OrderResponseType, OrderType } from "../type/orderType"; import api from "../utils/api"; interface OrdersExtendResponseType { data: OrderType[]; pagination: { currentPage: number; perPage: number; nextPage: number | null; prevPage: number | null; hasNextPage: boolean; }; } interface OrderTrackingResponseType extends AuthResponseBodyType { data: { order: string; tracking_status: string; driver_latitude: string; driver_longitude: string; driver_speed: string; note: string; countdown_seconds: string; customer_latitude: string; customer_longitude: string; polyline: string; restaurant_polyline?: string; estimatedDuration: null | string; distanceMeters: null | number; } } export const useFetchOrdersQuery = (options: { perPage?: number; order?: string; orderby?: string; search?: string; }) => { const fetchOrdersFunc = async ({ pageParam = 1, }): Promise => { try { const res = await api.get(`/api/v1/orders`, { params: { page: pageParam, per_page: options.perPage, order: options.order, orderby: options.orderby, search: options.search, } }) return await res.data; } catch (error) { return Promise.reject(error); } }; const { data, fetchNextPage, fetchPreviousPage, hasNextPage, hasPreviousPage, isFetchingNextPage, isFetchingPreviousPage, ...rest } = useInfiniteQuery({ queryKey: ["orders", options.perPage, options.order, options.orderby, options.search], // @ts-ignore queryFn: fetchOrdersFunc, initialPageParam: 1, keepPreviousData: true, getNextPageParam: (last) => last.pagination.nextPage ?? undefined, getPreviousPageParam: (last) => last.pagination.prevPage ?? undefined, refetchOnWindowFocus: false, refetchOnReconnect: false, }); return { data, fetchNextPage, fetchPreviousPage, hasNextPage: hasNextPage ?? false, hasPreviousPage: hasPreviousPage ?? false, isFetchingNextPage, isFetchingPreviousPage, ...rest, }; }; export const useFtechOrderTrackingQuery = (options: { orderId: string; }) => { const fetchOrderTrackingFunc = async (orderId: string) => { try { const res = await api.get(`/api/v1/orders/${orderId}/track`) return await res.data; } catch (error) { return Promise.reject(error); } } return useQuery({ queryKey: ["orderTracking", options.orderId], queryFn: () => fetchOrderTrackingFunc(options.orderId), enabled: !!options.orderId, // Screen-level polling already controls refresh cadence in order details. refetchOnWindowFocus: false, refetchOnReconnect: false, staleTime: 5000, gcTime: 5 * 60 * 1000, }) } export const useFetchOrderDetailsQuery = (options: { orderId: string; }) => { const fetchOrdersFunc = async (orderId: string) => { try { const res = await api.get(`/api/v1/orders/${orderId}`); return await res.data } catch (error) { return Promise.reject(error); } }; return useQuery<{ data: OrderResponseType, meesage: string }>({ queryKey: ["orderDetails", options.orderId], queryFn: () => fetchOrdersFunc(options.orderId), enabled: !!options.orderId, refetchOnWindowFocus: false, refetchOnReconnect: false, staleTime: 30 * 1000, gcTime: 5 * 60 * 1000, }) }; export const useMutationCreateOrder = () => { return useMutation({ mutationFn: async (order) => { try { const res = await api.post(`/api/v1/orders`, { ...order }) return await res.data; } catch (error) { return Promise.reject(error); } }, onSuccess: async (responseData) => { }, onError: (err) => { throw err; }, }); }; The Chef’s Wife Cafe – Page 4 – Rushlane
Sort by:
240.00
0 out of 5
Closed!
0
Price range: ₹170.00 through ₹220.00
0 out of 5
Closed!
0
Price range: ₹100.00 through ₹220.00
0 out of 5
Closed!
170.00
0 out of 5
Closed!
140.00
0 out of 5
Closed!

Passionately created in the heart ❤️ of Tura.

© 2024-2025 Rushlane. All rights reserved.

Shopping cart0
There are no products in the cart!
You may be interested in…
Placeholder
Price range: ₹88.20 through ₹167.40
Chicken Pakora
Price range: ₹84.00 through ₹150.86
Pork Chow
Price range: ₹84.00 through ₹195.43
Chicken Chow
Price range: ₹106.29 through ₹195.43
Chicken Drumstick
Original price was: ₹93.33.Current price is: ₹84.00.
Continue shopping
0
Select an available coupon below