@@ -20,6 +20,12 @@ def __init__(self, db, tg_user_id, texts):
2020 self .db = db
2121 self .tg_user_id = tg_user_id
2222 self .texts = texts
23+ self .back_to_menu_button = [
24+ InlineKeyboardButton (
25+ self .texts ["back_to_menu_button" ],
26+ callback_data = self .texts ["back_to_menu_button" ],
27+ )
28+ ]
2329
2430 def create_customer_menu_buttons (self ):
2531 """Create buttons for the customer menu."""
@@ -65,14 +71,7 @@ def __build_show_products_menu(self) -> InlineKeyboardMarkup:
6571 buttons .append ([button ])
6672 else :
6773 logging .getLogger (__name__ ).info ("No products in database" )
68- buttons .append (
69- [
70- InlineKeyboardButton (
71- self .texts ["back_to_menu_button" ],
72- callback_data = self .texts ["back_to_menu_button" ],
73- )
74- ]
75- )
74+ buttons .append (self .back_to_menu_button )
7675 return InlineKeyboardMarkup (buttons )
7776
7877 def __build_show_product_info_menu (self , data ) -> InlineKeyboardMarkup :
@@ -87,12 +86,7 @@ def __build_show_product_info_menu(self, data) -> InlineKeyboardMarkup:
8786 callback_data = self .texts ["show_products_button" ],
8887 )
8988 ],
90- [
91- InlineKeyboardButton (
92- self .texts ["back_to_menu_button" ],
93- callback_data = self .texts ["back_to_menu_button" ],
94- )
95- ],
89+ self .back_to_menu_button ,
9690 ]
9791 return InlineKeyboardMarkup (buttons )
9892
@@ -118,12 +112,7 @@ def __build_pre_approve_order_menu(self, data) -> InlineKeyboardMarkup:
118112 callback_data = self .texts ["make_order_button" ],
119113 )
120114 ],
121- [
122- InlineKeyboardButton (
123- self .texts ["back_to_menu_button" ],
124- callback_data = self .texts ["back_to_menu_button" ],
125- )
126- ],
115+ self .back_to_menu_button ,
127116 ]
128117 return InlineKeyboardMarkup (buttons )
129118
@@ -133,12 +122,7 @@ def __build_approve_order_menu(self, pre_data) -> InlineKeyboardMarkup:
133122 """
134123 buttons = [
135124 [InlineKeyboardButton (self .texts ["back_button" ], callback_data = pre_data )],
136- [
137- InlineKeyboardButton (
138- self .texts ["back_to_menu_button" ],
139- callback_data = self .texts ["back_to_menu_button" ],
140- )
141- ],
125+ self .back_to_menu_button ,
142126 ]
143127 return InlineKeyboardMarkup (buttons )
144128
@@ -158,14 +142,7 @@ def __build_show_orders_menu(self) -> InlineKeyboardMarkup:
158142 logging .getLogger (__name__ ).info (
159143 "No orders found for user %s" , self .tg_user_id
160144 )
161- buttons .append (
162- [
163- InlineKeyboardButton (
164- self .texts ["back_to_menu_button" ],
165- callback_data = self .texts ["back_to_menu_button" ],
166- )
167- ]
168- )
145+ buttons .append (self .back_to_menu_button )
169146 return InlineKeyboardMarkup (buttons )
170147
171148 def __build_show_order_info_menu (self ) -> InlineKeyboardMarkup :
@@ -179,12 +156,7 @@ def __build_show_order_info_menu(self) -> InlineKeyboardMarkup:
179156 callback_data = self .texts ["show_orders_button" ],
180157 )
181158 ],
182- [
183- InlineKeyboardButton (
184- self .texts ["back_to_menu_button" ],
185- callback_data = self .texts ["back_to_menu_button" ],
186- )
187- ],
159+ self .back_to_menu_button ,
188160 ]
189161 return InlineKeyboardMarkup (buttons )
190162
0 commit comments