import { Context , Logger , UseMakeOrder , useMakeOrderFactory , UseMakeOrderFactoryParams , } from '@vue-storefront/core' ; import { Order } from '@vue-storefront/magento-api' ; import useCart from '../useCart' ; const factoryParams = { provide ( ) { return { cart : useCart ( ) , } ; } , make : async ( context , params ) : Promise < Order > => { Logger . debug ( '[Magento] Make Order' , { params } ) ; const { id } = context . cart . cart . value ; const { data } = await context . $magento . api . placeOrder ( { cart_id : id } ) ; Logger . debug ( '[Result]:' , { data } ) ; return data . placeOrder . order ; } , } ; const useMakeOrder = useMakeOrderFactory < Order > ( factoryParams ) ; export default useMakeOrder ;