Implement catering order flow
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
from typing import Literal
|
||||
from typing import Literal, Callable
|
||||
|
||||
from rio import Component, Rectangle, Column, Spacer, Text, Row, TextInput, FlowContainer
|
||||
from rio import Component, Rectangle, Column, Spacer, Text
|
||||
from rio.event import on_populate
|
||||
|
||||
from elm.components import ElmButton, CateringItemBox
|
||||
from elm.components import CateringItemBox
|
||||
from elm.types.CateringTypes import CateringMenuItem, CateringMenuItemCategory
|
||||
|
||||
ITEM_CATEGORY_BY_DISPLAY_CATEGORY: dict[Literal["Frühstück", "Hauptspeisen", "Snacks & Dessert", "Softdrinks", "Alkohol"], list[CateringMenuItemCategory]] = {
|
||||
@@ -17,6 +17,7 @@ ITEM_CATEGORY_BY_DISPLAY_CATEGORY: dict[Literal["Frühstück", "Hauptspeisen", "
|
||||
|
||||
class CateringCategoryDisplay(Component):
|
||||
active_category: Literal["Frühstück", "Hauptspeisen", "Snacks & Dessert", "Softdrinks", "Alkohol"]
|
||||
add_to_cart_pressed_callback: Callable
|
||||
catering_menu_items: list[CateringMenuItem] = []
|
||||
|
||||
@on_populate
|
||||
@@ -28,6 +29,10 @@ class CateringCategoryDisplay(Component):
|
||||
}
|
||||
}
|
||||
).to_list()
|
||||
|
||||
async def add_to_cart_pressed(self, item: CateringMenuItem, changed_options: dict[str, bool]) -> None:
|
||||
await self.add_to_cart_pressed_callback(item, changed_options)
|
||||
|
||||
def build(self) -> Component:
|
||||
if len(self.catering_menu_items) <= 0:
|
||||
return Spacer()
|
||||
@@ -44,7 +49,7 @@ class CateringCategoryDisplay(Component):
|
||||
stroke_color=self.session.theme.box_border_color,
|
||||
),
|
||||
# Items here
|
||||
Column(*[CateringItemBox(i, margin=0.5, grow_y=True) for i in self.catering_menu_items]),
|
||||
Column(*[CateringItemBox(item=i, add_to_cart_pressed_callback=self.add_to_cart_pressed, margin=0.5, grow_y=True) for i in self.catering_menu_items]),
|
||||
Spacer()
|
||||
),
|
||||
fill=self.session.theme.box_color,
|
||||
|
||||
Reference in New Issue
Block a user