Modules

Products

The catalogue with stock per variant, sales trends, margins, list and grid views and a quick view.

composables/useProducts.ts
View in the demo

Products carry cost, an optional compareAtPrice, variants with their own stock, lowStockThreshold, an optional restockAt and 30 days of dailySales. Stock state, margin, discount and days left are derived.

Files

File
Role
pages/e-commerce/products.vueThe catalogue.
composables/useProducts.tsProducts and save, setStatus (publish or archive), duplicate, restock and remove.
composables/useProductForm.tsThe schema of the create and edit form.
types/models/products.tsProducts and variants.
config/products.config.tsViews, category icons and stock thresholds.
utils/products.tsPure rules, unit tested.
components/pages/products/ProductCard, ProductQuickView, ProductSalesCell, ProductStockCell.

Data

useProducts() loads its data through a ProductsProvider (types/models/products.ts); the demo uses createProductsMockProvider(). Write a provider that calls your API and make it the default: the pages do not change. See Connect your API.

Permissions

Viewing needs products.view; create and duplicate products.create; edit and archive products.update; delete products.delete. Buttons hide with can().

Configuration

PRODUCT_VIEWS

The views: all, active and low stock.

config/products.config.ts
const PRODUCT_VIEWS: ProductView[]

PRODUCT_DEFAULT_VIEW_MODE

list or grid; the choice persists in the products-layout cookie.

config/products.config.ts
const PRODUCT_DEFAULT_VIEW_MODE: ProductViewMode

PRODUCT_SALES_DAYS

Days of sales history.

config/products.config.ts
const PRODUCT_SALES_DAYS: 30

PRODUCT_RUNNING_LOW_DAYS

Days left that count as running low.

config/products.config.ts
const PRODUCT_RUNNING_LOW_DAYS: 7

PRODUCT_DEFAULT_LOW_STOCK

The default low stock threshold.

config/products.config.ts
const PRODUCT_DEFAULT_LOW_STOCK: 5

PRODUCT_CATEGORY_STYLES

The icon and colour of each category.

config/products.config.ts
const PRODUCT_CATEGORY_STYLES: Record<string, { icon: string; color: string; }>

Rules

Pure functions in utils/, unit tested in tests/unit/. Statuses and segments are derived from the stored data, never stored themselves.

productStock()

Total stock.

utils/products.ts
productStock(product: Pick<Product, 'variants'>): number

productStockState()

The stock state.

utils/products.ts
productStockState(product: StockFields): ProductStockState

productSalesTrend()

The sales trend.

utils/products.ts
productSalesTrend(product: Pick<Product, 'dailySales'>): number

productDaysLeft()

Days of stock left.

utils/products.ts
productDaysLeft(product: Pick<Product, 'variants' | 'dailySales'>): number | undefined

productMargin()

The margin.

utils/products.ts
productMargin(product: Pick<Product, 'price' | 'cost'>): number

productAttention()

Products that need attention.

utils/products.ts
productAttention(products: Product[]): { out: number; runningLow: number; }
ReturnsoutrunningLow

How it works

  • Operational screens have no KPI cards: analytics live in the dashboards. A warning BaseAlert appears only when something needs attention, and its action filters the table.
  • Views and the list/grid toggle are BaseToggleGroup compact fit in the table toolbar. Drafts and archived products go through the status filter.
  • The grid renders ProductCards through the BaseDataTable #body slot, so search, filters, sorting and pagination stay shared. The table is keyed by the layout because slots are read once.
  • Clicking a row or card opens ProductQuickView: price, cost, margin, a sales BaseSparkline, stock per variant, recent orders and the actions.
  • Create and edit stay in BaseFormPanel + BaseForm.
© 2026 melsami UI.
Developer documentation for melsami UI.