import {useShopActionInfiniteQuery} from '../../internal/reactQuery' import {useShopActions} from '../../internal/useShopActions' import { PaginatedDataHookOptionsBase, PaginatedDataHookReturnsBase, Order, } from '../../types' export interface UseOrdersParams extends PaginatedDataHookOptionsBase {} export interface UseOrdersReturns extends PaginatedDataHookReturnsBase { orders: Order[] | null } export const useOrders = (params?: UseOrdersParams): UseOrdersReturns => { const {skip, ...shopActionParams} = params || {} const {getOrders} = useShopActions() const {data, ...rest} = useShopActionInfiniteQuery( ['orders', shopActionParams], getOrders, shopActionParams, {skip} ) return { ...rest, orders: data, } } /** * The `useOrders` hook fetches the user's recent order history from all Shop stores, sorted by most recent first. Use this for order history pages, reorder functionality, tracking shipments, or customer support features. Orders are aggregated across all merchants the user has purchased from through Shop. * * * > Caution: This hook requires adding the following scopes to the manifest file: * > * > `orders` * > * > For more details, see [manifest.json](/docs/api/shop-minis/manifest-file). * * @publicDocs */ export type UseOrdersGeneratedType = ( params?: UseOrdersParams ) => UseOrdersReturns