62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
from aiogram_dialog import Dialog, Window
|
|
from aiogram_dialog.widgets.kbd import Row, Start, Back, Button
|
|
from aiogram_dialog.widgets.text import Format, Const
|
|
from aiogram_dialog.widgets.kbd import ScrollingGroup, Select
|
|
from bot.getters import get_history_account_details, get_purchase_history
|
|
from bot.getters import username_getter
|
|
from bot.services import on_history_account_selected
|
|
from bot.states import PurchaseHistorySG, UpBalanceSG, ProfileSG, StartSG
|
|
|
|
PROFILE_BACK_BUTTON = Start(Const("🔙 Назад"), id="back", state=StartSG.start)
|
|
HISTORY_BACK_BUTTON = Start(Const("🔙 Назад"), id="back", state=ProfileSG.profile)
|
|
|
|
|
|
profile_dialog = Dialog(
|
|
Window(
|
|
Format("<b>Профиль {username}:</b>\n"),
|
|
Format("💰 Баланс: {balance}₽"),
|
|
Format("🛒 Количество покупок: {purchased}"),
|
|
Row(
|
|
Start(
|
|
Const("🛍️ История покупок"),
|
|
id="history",
|
|
state=PurchaseHistorySG.history,
|
|
),
|
|
Start(
|
|
Const("💰 Пополнить баланс"),
|
|
id="up_balance",
|
|
state=UpBalanceSG.up_balance,
|
|
),
|
|
),
|
|
PROFILE_BACK_BUTTON,
|
|
getter=username_getter,
|
|
state=ProfileSG.profile,
|
|
)
|
|
)
|
|
|
|
history_dialog = Dialog(
|
|
Window(
|
|
Format("{text}"),
|
|
ScrollingGroup(
|
|
Select(
|
|
Format("{item[0]}"),
|
|
id="history_account_select",
|
|
item_id_getter=lambda x: x[1],
|
|
items="purchased_accounts",
|
|
on_click=on_history_account_selected,
|
|
),
|
|
id="purchased_accounts_group",
|
|
width=1,
|
|
height=6,
|
|
),
|
|
HISTORY_BACK_BUTTON,
|
|
state=PurchaseHistorySG.history,
|
|
getter=get_purchase_history,
|
|
),
|
|
Window(
|
|
Format("{account_info}"),
|
|
Button(Const("🔙 Назад"), id="back_to_history", on_click=Back()),
|
|
state=PurchaseHistorySG.details,
|
|
getter=get_history_account_details,
|
|
),
|
|
) |