🧹 Конфиг: услуги, мастера и время вынесены в config.py
- SERVICES, MASTERS, TIME_SLOTS в config.py - Клавиатуры services.py, masters.py, time_slots.py берут данные из config - booking.py импортирует services/masters из config вместо хардкода - time_slots отображает занятые слоты как ❌, свободные как ✅
This commit is contained in:
@@ -1,28 +1,10 @@
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from app.config import MASTERS
|
||||
|
||||
|
||||
def get_masters_keyboard():
|
||||
|
||||
return InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="👩 Анна",
|
||||
callback_data="master_anna"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="👩 Мария",
|
||||
callback_data="master_maria"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="👨 Алексей",
|
||||
callback_data="master_alex"
|
||||
)
|
||||
]
|
||||
]
|
||||
)
|
||||
buttons = [
|
||||
[InlineKeyboardButton(text=name, callback_data=key)]
|
||||
for key, name in MASTERS.items()
|
||||
]
|
||||
return InlineKeyboardMarkup(inline_keyboard=buttons)
|
||||
|
||||
@@ -1,28 +1,10 @@
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from app.config import SERVICES
|
||||
|
||||
|
||||
def get_services_keyboard():
|
||||
|
||||
return InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="💆 Массаж",
|
||||
callback_data="service_massage"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="🌿 SPA",
|
||||
callback_data="service_spa"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="✨ Косметология",
|
||||
callback_data="service_cosmetology"
|
||||
)
|
||||
]
|
||||
]
|
||||
)
|
||||
buttons = [
|
||||
[InlineKeyboardButton(text=name, callback_data=key)]
|
||||
for key, name in SERVICES.items()
|
||||
]
|
||||
return InlineKeyboardMarkup(inline_keyboard=buttons)
|
||||
|
||||
+16
-38
@@ -1,41 +1,19 @@
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from app.config import TIME_SLOTS
|
||||
|
||||
|
||||
def get_time_keyboard(
|
||||
busy_times=None
|
||||
):
|
||||
|
||||
if busy_times is None:
|
||||
busy_times = []
|
||||
|
||||
times = [
|
||||
"10:00",
|
||||
"11:00",
|
||||
"12:00",
|
||||
"13:00",
|
||||
"14:00",
|
||||
"15:00",
|
||||
"16:00",
|
||||
"17:00"
|
||||
]
|
||||
|
||||
def get_time_keyboard(busy_times):
|
||||
buttons = []
|
||||
|
||||
for time in times:
|
||||
|
||||
if time in busy_times:
|
||||
continue
|
||||
|
||||
buttons.append(
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=time,
|
||||
callback_data=f"time_{time}"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
return InlineKeyboardMarkup(
|
||||
inline_keyboard=buttons
|
||||
)
|
||||
row = []
|
||||
for slot in TIME_SLOTS:
|
||||
if slot in busy_times:
|
||||
label = f❌ {slot}
|
||||
else:
|
||||
label = f✅ {slot}
|
||||
row.append(InlineKeyboardButton(text=label, callback_data=ftime_{slot}))
|
||||
if len(row) == 3:
|
||||
buttons.append(row)
|
||||
row = []
|
||||
if row:
|
||||
buttons.append(row)
|
||||
return InlineKeyboardMarkup(inline_keyboard=buttons)
|
||||
|
||||
Reference in New Issue
Block a user