66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
from aiogram_dialog import Dialog, Window
|
|
from aiogram_dialog.widgets.kbd import Back, Button, Row, ScrollingGroup, Select, Start
|
|
from aiogram_dialog.widgets.text import Const, Format
|
|
|
|
from shopbot.bot.getters import (
|
|
get_history_account_details,
|
|
get_purchase_history,
|
|
username_getter,
|
|
)
|
|
from shopbot.bot.services import on_history_account_selected
|
|
from shopbot.bot.states import ProfileSG, PurchaseHistorySG, StartSG, UpBalanceSG
|
|
|
|
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,
|
|
),
|
|
)
|