Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
/** A count of finished items out of a total — an onboarding checklist, say. */
export interface ProgressCounts {
done: number
total: number
}
/**
* How far through a checklist something is, as a percentage for a progress bar.
*
* An empty checklist counts as complete rather than as nothing done: a
* marketplace that asks nothing of its sellers has no outstanding work, and
* `done / total` would be NaN.
*/
export function progressPercentage({ done, total }: ProgressCounts): number {
if (total <= 0) return 100
return Math.round((done / total) * 100)
}