setup profile edition

This commit is contained in:
2025-09-27 10:56:32 +03:00
parent 1a49545fff
commit 0875624aa5
6 changed files with 101 additions and 14 deletions

View File

@@ -5,37 +5,55 @@ from aiogram_dialog.widgets.text import Const, Format
from app.bot.dialogs.widgets.getters import user_getter
from .getters import phone_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(
Const("*Профиль*"),
Format("Имя: {user.fullname}"),
Format("Телефон: {user.phone}"),
Const("*Профиль*\n"),
Format("*Имя*: {user.fullname}"),
Format("*Телефон*: {phone}"),
SwitchTo(
Const("изменить имя"),
Const("✏️ изменить имя"),
id="change_name",
state=ProfileSG.change_name,
),
SwitchTo(
Const("изменить телефон"),
Const("📞 изменить телефон"),
id="change_phone",
state=ProfileSG.change_phone,
),
Cancel(Const("назад")),
Cancel(Const("◀️ назад")),
state=ProfileSG.profile,
getter=user_getter,
getter=[user_getter, phone_getter],
),
Window(
Const("Введите имя"),
SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile),
TextInput(id="name_input"),
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"),
TextInput(
id="phone_input",
type_factory=phone_type_factory,
on_success=update_user_phone,
on_error=on_error,
),
state=ProfileSG.change_phone,
),
)