@pagamio/frontend-commons-lib 0.8.331 → 0.8.332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,8 +5,11 @@ import { formatPrice } from '../../helpers/utils';
|
|
|
5
5
|
import ImageComponent from '../ui/ImageComponent';
|
|
6
6
|
const LOW_STOCK_THRESHOLD = 5;
|
|
7
7
|
export function ProductCard({ product, onAddToCart, isAddingToCart, storeId, basePath = '/shop', featured = false, linkSuffix, currency = 'ZAR', renderLink, onNavigate, }) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// Non-stock products (services / fees / digital goods) have no
|
|
9
|
+
// StockItem rows by design — they're always available
|
|
10
|
+
const isNonStock = product.isStockItem === false;
|
|
11
|
+
const hasStock = isNonStock || product.totalStock > 0;
|
|
12
|
+
const isLowStock = !isNonStock && hasStock && product.totalStock <= LOW_STOCK_THRESHOLD;
|
|
10
13
|
const isBackorderable = product.allowBackorders === true;
|
|
11
14
|
const canAddToCart = (hasStock || isBackorderable) && !!storeId;
|
|
12
15
|
const hasVariants = product.variants && product.variants.length > 0;
|
|
@@ -33,6 +33,13 @@ export interface EcommerceProduct {
|
|
|
33
33
|
totalStock: number;
|
|
34
34
|
inStock?: boolean;
|
|
35
35
|
allowBackorders?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* False for services / fees / digital goods that don't hold inventory.
|
|
38
|
+
* The card treats these as always available — no out-of-stock badge,
|
|
39
|
+
* no low-stock warning. Defaults to true (or undefined) for stock
|
|
40
|
+
* products which retain the existing behaviour.
|
|
41
|
+
*/
|
|
42
|
+
isStockItem?: boolean;
|
|
36
43
|
variants?: ProductVariant[];
|
|
37
44
|
}
|
|
38
45
|
export interface CartItemBundleItem {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.332",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|