@popmenu/ordering-ui 0.119.0 → 0.120.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
- /** Modifiers of the dish in tuple format */
5
- modifiers?: [string, string][];
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,13 @@ 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
+ selectedModifierGroups?: ModifierGroupsType[];
41
+ };
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, modifiers = props.modifiers, 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;
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,41 @@ 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.map(function (modifier) { return modifier.modifierName; }).join(', ');
1638
+ // Render nested groups recursively
1639
+ var nestedGroups = group.selectedModifiers.flatMap(function (modifier) {
1640
+ var _a;
1641
+ 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
1642
+ ? formatModifiers(modifier.selectedModifierGroups, true)
1643
+ : [];
1644
+ });
1645
+ // For top-level groups, we render without the list
1646
+ if (!nested) {
1647
+ return (React__default.createElement(Typography, { key: group.id, variant: "body2" },
1648
+ group.menuItemModifierGroupName,
1649
+ ": ",
1650
+ modifiers,
1651
+ (nestedGroups === null || nestedGroups === void 0 ? void 0 : nestedGroups.length) > 0 && React__default.createElement("ul", { className: classes.ul }, nestedGroups)));
1652
+ }
1653
+ // For nested groups, we use list items
1654
+ return (React__default.createElement("li", { key: group.id, className: classes.li },
1655
+ React__default.createElement(Typography, { variant: "body2" },
1656
+ group.menuItemModifierGroupName,
1657
+ ": ",
1658
+ modifiers,
1659
+ nestedGroups && nestedGroups.length > 0 && React__default.createElement("ul", { className: classes.ul }, nestedGroups))));
1660
+ });
1661
+ };
1629
1662
  return (React__default.createElement(Box, { className: classes.root },
1630
1663
  React__default.createElement(Box, { display: "flex", gridGap: 3 },
1631
1664
  src && alt && React__default.createElement("img", { src: src, alt: alt, className: classes.img }),
1632
1665
  React__default.createElement(Box, { flexGrow: 1 },
1633
1666
  React__default.createElement(Typography, { variant: "h2", className: classes.name }, name),
1634
- modifiers &&
1635
- modifiers.map(function (modifier, i) { return (React__default.createElement(Typography, { key: i, variant: "body2" },
1636
- modifier[0],
1637
- ": ",
1638
- modifier[1])); }),
1667
+ modifierGroups && formatModifiers(modifierGroups),
1639
1668
  specialInstructions && React__default.createElement(Typography, { variant: "body2" },
1640
1669
  "\"",
1641
1670
  specialInstructions,