60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
from aiogram_dialog import Dialog, Window
|
|
from aiogram_dialog.widgets.input import TextInput
|
|
from aiogram_dialog.widgets.kbd import Cancel, SwitchTo
|
|
from aiogram_dialog.widgets.text import Const, Jinja
|
|
|
|
from app.bot.dialogs.templates import profile_template
|
|
from app.bot.dialogs.widgets.getters import user_getter
|
|
|
|
from .handlers import (
|
|
name_type_factory,
|
|
on_error,
|
|
phone_type_factory,
|
|
update_user_name,
|
|
update_user_phone,
|
|
)
|
|
from .states import ProfileSG
|
|
|
|
profile_dialog = Dialog(
|
|
Window(
|
|
Jinja(profile_template),
|
|
SwitchTo(
|
|
Const("✏️ изменить имя"),
|
|
id="change_name",
|
|
state=ProfileSG.change_name,
|
|
),
|
|
SwitchTo(
|
|
Const("📞 изменить телефон"),
|
|
id="change_phone",
|
|
state=ProfileSG.change_phone,
|
|
),
|
|
Cancel(Const("◀️ назад")),
|
|
getter=user_getter,
|
|
parse_mode="HTML",
|
|
state=ProfileSG.profile,
|
|
),
|
|
Window(
|
|
Const("Введите имя"),
|
|
SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile),
|
|
TextInput(
|
|
id="name_input",
|
|
type_factory=name_type_factory,
|
|
on_success=update_user_name,
|
|
on_error=on_error,
|
|
),
|
|
state=ProfileSG.change_name,
|
|
),
|
|
Window(
|
|
Const("Введите телефон"),
|
|
SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile),
|
|
TextInput(
|
|
id="phone_input",
|
|
type_factory=phone_type_factory,
|
|
on_success=update_user_phone,
|
|
on_error=on_error,
|
|
),
|
|
state=ProfileSG.change_phone,
|
|
parse_mode="Markdown",
|
|
),
|
|
)
|