chore: minor fixes and formatting

This commit is contained in:
2026-08-12 19:52:30 +07:00
parent a011b2724b
commit ca276cdd61
48 changed files with 394 additions and 354 deletions

View File

@@ -1,7 +1,10 @@
from typing import Optional, Callable, Union
from collections.abc import Callable
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from aiogram.utils.keyboard import InlineKeyboardBuilder
from db.models import Product
main_menu: InlineKeyboardMarkup = InlineKeyboardBuilder(
[
[InlineKeyboardButton(text="📦 Изменить каталог", callback_data="cat:root")],
@@ -10,22 +13,18 @@ main_menu: InlineKeyboardMarkup = InlineKeyboardBuilder(
).as_markup()
def back_to_product_kb(
product_id: Union[int, str], *, cb_factory: Callable[[int | str], str]
):
def back_to_product_kb(product_id: int | str, *, cb_factory: Callable[[int | str], str]):
return InlineKeyboardBuilder(
[[InlineKeyboardButton(text="⬅️", callback_data=cb_factory(product_id))]]
).as_markup()
def customer_contacts(
user_id: int, has_mention: bool, mention: Optional[str] = None
user_id: int, has_mention: bool, mention: str | None = None
) -> InlineKeyboardMarkup:
btns: list[list[InlineKeyboardButton]] = []
(
btns.append(
[InlineKeyboardButton(text="👤 Перейти", url=f"https://t.me/{mention}")]
)
btns.append([InlineKeyboardButton(text="👤 Перейти", url=f"https://t.me/{mention}")])
if has_mention
else None
)
@@ -40,9 +39,7 @@ def customer_contacts(
def payment_link(url: str) -> InlineKeyboardMarkup:
return InlineKeyboardBuilder(
[[InlineKeyboardButton(text="💸 Оплатить", url=url)]]
).as_markup()
return InlineKeyboardBuilder([[InlineKeyboardButton(text="💸 Оплатить", url=url)]]).as_markup()
def verify_payment(invoice_id: int):
@@ -57,14 +54,15 @@ def verify_payment(invoice_id: int):
).as_markup()
def edit_product(product_id: int, category_id: int):
def edit_product(product: Product):
product_id = product.id
prefix = f"edit_product:{product_id}"
visibility_btn = "🙈 Скрыт" if product.is_hidden else "👁️ Видим"
return InlineKeyboardBuilder(
[
[
InlineKeyboardButton(
text="✍️ Название", callback_data=f"{prefix}:name"
),
InlineKeyboardButton(text="✍️ Название", callback_data=f"{prefix}:name"),
InlineKeyboardButton(
text="✍️ Описание",
callback_data=f"{prefix}:description",
@@ -72,9 +70,9 @@ def edit_product(product_id: int, category_id: int):
],
[InlineKeyboardButton(text="💸 Цена", callback_data=f"{prefix}:price")],
[
InlineKeyboardButton(text="👁️", callback_data=f"{prefix}:hide"),
InlineKeyboardButton(text=visibility_btn, callback_data=f"{prefix}:hide"),
InlineKeyboardButton(text="❌", callback_data=f"{prefix}:delete"),
],
[InlineKeyboardButton(text="⬅️", callback_data=f"cat:{category_id}")],
[InlineKeyboardButton(text="⬅️", callback_data=f"cat:{product.category_id}")],
]
).as_markup()