useCompanyOrders
The useCompanyOrders composable provides utilities for managing company orders data and table display. It handles fetching, transforming, and displaying company orders with proper formatting, column configuration, and reactive state management.
NOTE
This composable is designed specifically for company orders-related functionalities and may not be suitable for general use cases.
Features
- Reactive orders list with automatic table column generation
- Data transformation from API format to display-ready format
- Column configuration with internationalization and type formatting
Usage
Basic Usage
const { ordersList, orderColumns, fetchOrders } = useCompanyOrders();
await fetchOrders(
orderSelectionQuery,
{ fields: ['priceLists', 'itemcount'] },
entityId.value,
allPriceLists.value,
allCompanies.value,
buyersList.value,
);<TableView :columns="orderColumns" :data="ordersList" entity-name="order" />Properties and Methods
ordersList
A ref containing the list of transformed customer orders.
orderColumns
A computed property that generates table columns based on ordersList and columnOptionsOrders.
columnOptionsOrders
An object defining column configuration options for customer orders, including:
fetchOrders
fetchOrders(
orderSelectionQuery?: OrderBatchQuery,
orderApiOptions?: OrderApiOptions,
allPriceLists?: CustomerPriceList[],
allCompanies?: CustomerCompany[]
allBuyers?: CompanyBuyer[],
): Promise<void>Fetches orders from the API with filtering and transformation.
Parameters:
orderSelectionQuery: Query filters for ordersorderApiOptions: API options (e.g. fields to include)allPriceLists: Price list entities for name resolution, will add price lists column if providedallCompanies: Company entities for name resolution, will add company column if providedallBuyers: Buyer entities for name resolution, will add buyer column if provided
Features: Error handling, data caching, automatic transformation
transformOrdersForList
transformOrdersForList(
orders: Order[],
allPriceLists?: CustomerPriceList[],
allCompanies?: CustomerCompany[]
allBuyers?: CompanyBuyer[],
): CustomerOrder[]Transforms raw API orders to display-ready format. Used internally by fetchOrders.
Parameters:
orders: Raw orders from APIallPriceLists: Optional price list entities for resolutionallCompanies: Optional company entities for resolutionallBuyers: Optional buyer entities for resolution
Returns: Array of transformed customer orders
Features: Price formatting, entity name resolution, tooltip creation
Type Definitions
function useCompanyOrders(): UseCompanyOrdersReturnType;
interface UseCompanyOrdersReturnType {
ordersList: Ref<CustomerOrder[]>;
orderColumns: ComputedRef<ColumnDef<CustomerOrder>[]>;
columnOptionsOrders: ColumnOptions<CustomerOrder>;
fetchOrders: (
orderSelectionQuery?: OrderBatchQuery,
orderApiOptions?: OrderApiOptions,
allPriceLists?: CustomerPriceList[],
allCompanies?: CustomerCompany[],
) => Promise<void>;
transformOrdersForList: (
orders: Order[],
allPriceLists?: CustomerPriceList[],
allCompanies?: CustomerCompany[],
) => CustomerOrder[];
}Dependencies
This composable depends on:
- useI18n for internationalization