import { AgnosticPagination } from '@vue-storefront/core' ; export const getDate = ( order ) : string => new Date ( order ?. created_at ) . toLocaleDateString ( ) || '' ; export const getId = ( order ) : string => String ( Number . parseInt ( order ?. order_number , 10 ) || Math . floor ( Math . random ( ) * 100 ) ) ; export const getStatus = ( order ) : string => order ?. status || 'Failed' ; export const getPrice = ( order ) : number | null => order ?. grand_total || 0 ; export const getItems = ( order ) : any [ ] => order ?. items || [ ] ; export const getItemSku = ( item ) : string => item ?. product_sku || 0 ; export const getItemName = ( item ) : string => item ?. product_name || 0 ; export const getItemQty = ( item ) : number => item ?. quantity_ordered || 0 ; export const getItemPrice = ( item ) : number => item ?. product_sale_price ?. value || 0 ; export const getFormattedPrice = ( price ) => String ( price ) ; const getPagination = ( orders ) : AgnosticPagination => ( { currentPage : orders ?. page_info ?. current_page || 1 , totalPages : orders ?. page_info ?. total_pages || 1 , totalItems : orders ?. total_count || 0 , itemsPerPage : orders ?. page_info ?. page_size || 10 , pageOptions : [ 10 , 50 , 100 ] , } ) ; const orderGetters = { getDate , getId , getStatus , getPrice , getItems , getItemSku , getItemName , getItemQty , getItemPrice , getFormattedPrice , getPagination , } ; export default orderGetters ;