import { Context , Logger , useUserOrderFactory , UseUserOrderFactoryParams , } from '@vue-storefront/core' ; import { GetOrdersSearchParams } from '@vue-storefront/magento-api' ; import useUser from '../useUser' ; const factoryParams = { provide ( ) { return { user : useUser ( ) , } ; } , searchOrders : async ( context , params ) => { Logger . debug ( '[Magento] search user orders' , { params } ) ; if ( ! context . user . user ?. value ?. id ) { await context . user . load ( ) ; } const { data } = await context . $magento . api . customerOrders ( params ) ; Logger . debug ( '[Result]:' , { data } ) ; return data . customer . orders ; } , } ; export default useUserOrderFactory < any , GetOrdersSearchParams > ( factoryParams ) ;