@popmenu/ordering-ui 0.119.0 → 0.121.0
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface DishCheckoutCardProps {
|
|
2
2
|
/** Adds a border to the bottom of the card */
|
|
3
3
|
borderBottom?: boolean;
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/** Modifier group object of the dish */
|
|
5
|
+
modifierGroups?: ModifierGroupsType[];
|
|
6
6
|
/** Id of the dish */
|
|
7
7
|
id: number;
|
|
8
8
|
/** Dish image information */
|
|
@@ -29,3 +29,14 @@ export interface DishCheckoutCardProps {
|
|
|
29
29
|
/** If item is in cart but is not unavailable */
|
|
30
30
|
warningMessage?: string;
|
|
31
31
|
}
|
|
32
|
+
export declare type ModifierGroupsType = {
|
|
33
|
+
id: number;
|
|
34
|
+
menuItemModifierGroupName?: string | null;
|
|
35
|
+
selectedModifiers: ModifiersType[];
|
|
36
|
+
};
|
|
37
|
+
export declare type ModifiersType = {
|
|
38
|
+
id: number;
|
|
39
|
+
modifierName?: string | null;
|
|
40
|
+
quantity: number;
|
|
41
|
+
selectedModifierGroups?: ModifierGroupsType[];
|
|
42
|
+
};
|
package/build/index.es.js
CHANGED
|
@@ -1592,6 +1592,10 @@ var useDishCheckoutCardStyles = makeStyles(function (theme) { return ({
|
|
|
1592
1592
|
selectPaper: {
|
|
1593
1593
|
maxHeight: theme.spacing(37),
|
|
1594
1594
|
},
|
|
1595
|
+
ul: {
|
|
1596
|
+
margin: 0,
|
|
1597
|
+
paddingLeft: theme.spacing(3),
|
|
1598
|
+
},
|
|
1595
1599
|
warning: {
|
|
1596
1600
|
color: theme.palette.error.main,
|
|
1597
1601
|
display: 'flex',
|
|
@@ -1614,7 +1618,7 @@ var OrderingAppContextProvider = function (props) {
|
|
|
1614
1618
|
|
|
1615
1619
|
var DishCheckoutCard = function (props) {
|
|
1616
1620
|
var _a;
|
|
1617
|
-
var id = props.id, name = props.name, quantity = props.quantity,
|
|
1621
|
+
var id = props.id, name = props.name, quantity = props.quantity, modifierGroups = props.modifierGroups, onDelete = props.onDelete, onEdit = props.onEdit, onQuantityChange = props.onQuantityChange, price = props.price, specialInstructions = props.specialInstructions, disabled = props.disabled, warningMessage = props.warningMessage, _b = props.image, image = _b === void 0 ? {} : _b;
|
|
1618
1622
|
var src = image.src, alt = image.alt;
|
|
1619
1623
|
var classes = useDishCheckoutCardStyles(props);
|
|
1620
1624
|
var appContext = useOrderingAppContext()[0];
|
|
@@ -1626,16 +1630,45 @@ var DishCheckoutCard = function (props) {
|
|
|
1626
1630
|
var labelString = function (label) {
|
|
1627
1631
|
return label.replace(/[^a-zA-Z\s]/g, '').toLowerCase();
|
|
1628
1632
|
};
|
|
1633
|
+
var formatModifiers = function (groups, nested) {
|
|
1634
|
+
if (nested === void 0) { nested = false; }
|
|
1635
|
+
return groups.map(function (group) {
|
|
1636
|
+
// Get all selected modifiers for this group
|
|
1637
|
+
var modifiers = group.selectedModifiers
|
|
1638
|
+
.map(function (modifier) {
|
|
1639
|
+
return modifier.quantity > 1 ? modifier.modifierName + " \u00D7 " + modifier.quantity : modifier.modifierName;
|
|
1640
|
+
})
|
|
1641
|
+
.join(', ');
|
|
1642
|
+
// Render nested groups recursively
|
|
1643
|
+
var nestedGroups = group.selectedModifiers.flatMap(function (modifier) {
|
|
1644
|
+
var _a;
|
|
1645
|
+
return (modifier === null || modifier === void 0 ? void 0 : modifier.selectedModifierGroups) && ((_a = modifier === null || modifier === void 0 ? void 0 : modifier.selectedModifierGroups) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
1646
|
+
? formatModifiers(modifier.selectedModifierGroups, true)
|
|
1647
|
+
: [];
|
|
1648
|
+
});
|
|
1649
|
+
// For top-level groups, we render without the list
|
|
1650
|
+
if (!nested) {
|
|
1651
|
+
return (React__default.createElement(Typography, { key: group.id, variant: "body2" },
|
|
1652
|
+
group.menuItemModifierGroupName,
|
|
1653
|
+
": ",
|
|
1654
|
+
modifiers,
|
|
1655
|
+
(nestedGroups === null || nestedGroups === void 0 ? void 0 : nestedGroups.length) > 0 && React__default.createElement("ul", { className: classes.ul }, nestedGroups)));
|
|
1656
|
+
}
|
|
1657
|
+
// For nested groups, we use list items
|
|
1658
|
+
return (React__default.createElement("li", { key: group.id, className: classes.li },
|
|
1659
|
+
React__default.createElement(Typography, { variant: "body2" },
|
|
1660
|
+
group.menuItemModifierGroupName,
|
|
1661
|
+
": ",
|
|
1662
|
+
modifiers,
|
|
1663
|
+
nestedGroups && nestedGroups.length > 0 && React__default.createElement("ul", { className: classes.ul }, nestedGroups))));
|
|
1664
|
+
});
|
|
1665
|
+
};
|
|
1629
1666
|
return (React__default.createElement(Box, { className: classes.root },
|
|
1630
1667
|
React__default.createElement(Box, { display: "flex", gridGap: 3 },
|
|
1631
1668
|
src && alt && React__default.createElement("img", { src: src, alt: alt, className: classes.img }),
|
|
1632
1669
|
React__default.createElement(Box, { flexGrow: 1 },
|
|
1633
1670
|
React__default.createElement(Typography, { variant: "h2", className: classes.name }, name),
|
|
1634
|
-
|
|
1635
|
-
modifiers.map(function (modifier, i) { return (React__default.createElement(Typography, { key: i, variant: "body2" },
|
|
1636
|
-
modifier[0],
|
|
1637
|
-
": ",
|
|
1638
|
-
modifier[1])); }),
|
|
1671
|
+
modifierGroups && formatModifiers(modifierGroups),
|
|
1639
1672
|
specialInstructions && React__default.createElement(Typography, { variant: "body2" },
|
|
1640
1673
|
"\"",
|
|
1641
1674
|
specialInstructions,
|