@neowhale/storefront 0.2.21 → 0.2.25
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.
- package/dist/react/index.cjs +35 -3
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +35 -3
- package/dist/react/index.js.map +1 -1
- package/package.json +2 -2
package/dist/react/index.cjs
CHANGED
|
@@ -3149,13 +3149,24 @@ function buildDefaultSections(data) {
|
|
|
3149
3149
|
config: { align: "center" }
|
|
3150
3150
|
});
|
|
3151
3151
|
}
|
|
3152
|
+
const totalMg = toNum(cf?.total_mg_per_package ?? cf?.total_mg);
|
|
3153
|
+
const mgPerPiece = toNum(cf?.mg_per_piece);
|
|
3154
|
+
const piecesPerPkg = toNum(cf?.pieces_per_package);
|
|
3155
|
+
const isEdible = totalMg != null || mgPerPiece != null || piecesPerPkg != null;
|
|
3152
3156
|
const thca = toNum(cf?.thca_percentage);
|
|
3153
3157
|
const thc = toNum(cf?.d9_percentage);
|
|
3154
3158
|
const cbd = toNum(cf?.cbd_total);
|
|
3155
3159
|
const stats = [];
|
|
3156
|
-
if (
|
|
3157
|
-
|
|
3158
|
-
|
|
3160
|
+
if (isEdible) {
|
|
3161
|
+
if (totalMg != null) stats.push({ label: "Total MG", value: `${fmtMg(totalMg)}` });
|
|
3162
|
+
if (mgPerPiece != null) stats.push({ label: "Per Piece", value: `${fmtMg(mgPerPiece)}mg` });
|
|
3163
|
+
if (piecesPerPkg != null) stats.push({ label: "Pieces", value: `${piecesPerPkg}` });
|
|
3164
|
+
if (thc != null) stats.push({ label: "\u03949 THC", value: `${thc.toFixed(thc >= 1 ? 1 : 2)}%` });
|
|
3165
|
+
} else {
|
|
3166
|
+
if (thca != null) stats.push({ label: "THCa", value: `${thca.toFixed(thca >= 1 ? 1 : 2)}%` });
|
|
3167
|
+
if (thc != null) stats.push({ label: "\u03949 THC", value: `${thc.toFixed(thc >= 1 ? 1 : 2)}%` });
|
|
3168
|
+
if (cbd != null) stats.push({ label: "CBD", value: `${cbd.toFixed(cbd >= 1 ? 1 : 2)}%` });
|
|
3169
|
+
}
|
|
3159
3170
|
if (stats.length > 0) {
|
|
3160
3171
|
sections.push({
|
|
3161
3172
|
id: "auto-stats",
|
|
@@ -3164,6 +3175,24 @@ function buildDefaultSections(data) {
|
|
|
3164
3175
|
content: { stats }
|
|
3165
3176
|
});
|
|
3166
3177
|
}
|
|
3178
|
+
if (isEdible) {
|
|
3179
|
+
const servingDetails = [];
|
|
3180
|
+
const servingSize = toStr(cf?.serving_size);
|
|
3181
|
+
const ingredients = toStr(cf?.ingredients);
|
|
3182
|
+
const allergens = toStr(cf?.allergens);
|
|
3183
|
+
if (servingSize) servingDetails.push({ label: "Serving Size", value: servingSize });
|
|
3184
|
+
if (ingredients) servingDetails.push({ label: "Ingredients", value: ingredients });
|
|
3185
|
+
if (allergens) servingDetails.push({ label: "Allergens", value: allergens });
|
|
3186
|
+
if (servingDetails.length > 0) {
|
|
3187
|
+
sections.push({
|
|
3188
|
+
id: "auto-serving",
|
|
3189
|
+
type: "stats",
|
|
3190
|
+
order: order++,
|
|
3191
|
+
content: { stats: servingDetails },
|
|
3192
|
+
config: { layout: "list" }
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3167
3196
|
const profileDetails = [];
|
|
3168
3197
|
const genetics = toStr(cf?.genetics);
|
|
3169
3198
|
const terpenes = toStr(cf?.terpenes);
|
|
@@ -3235,6 +3264,9 @@ function toNum(v) {
|
|
|
3235
3264
|
const n = Number(v);
|
|
3236
3265
|
return Number.isFinite(n) ? n : null;
|
|
3237
3266
|
}
|
|
3267
|
+
function fmtMg(mg) {
|
|
3268
|
+
return mg === Math.floor(mg) ? `${mg}mg` : `${mg.toFixed(1)}mg`;
|
|
3269
|
+
}
|
|
3238
3270
|
function toStr(v) {
|
|
3239
3271
|
if (v == null || v === "") return null;
|
|
3240
3272
|
return String(v);
|