нейминг кнопок
This commit is contained in:
@@ -27,7 +27,7 @@ func (s *MainMenu) Enter(b *bot.Bot, mode bot.RenderMode) {
|
||||
URLButton("Поддержка", "https://example.com"),
|
||||
),
|
||||
Row(
|
||||
Button("Закупы", "purchases"),
|
||||
Button("Размещения", "placements"),
|
||||
URLButton("Дашборд", "https://example.com"),
|
||||
),
|
||||
)
|
||||
@@ -39,8 +39,8 @@ func (s *MainMenu) HandleCallback(b *bot.Bot, u *echotron.Update) {
|
||||
switch u.CallbackQuery.Data {
|
||||
case "my_projects":
|
||||
b.SetState(&MyProjects{BackState: &MainMenu{}}, bot.EditMessage)
|
||||
case "purchases":
|
||||
b.SetState(&MyProjects{BackState: &MainMenu{}, OpenPurchases: true}, bot.EditMessage)
|
||||
case "placements":
|
||||
b.SetState(&MyProjects{BackState: &MainMenu{}, OpenPlacements: true}, bot.EditMessage)
|
||||
default:
|
||||
s.Enter(b, bot.NewMessage)
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
const projectsPerPage = 6
|
||||
|
||||
type MyProjects struct {
|
||||
CurrentPage int
|
||||
WorkspaceID string
|
||||
BackState bot.State
|
||||
OpenPurchases bool
|
||||
CurrentPage int
|
||||
WorkspaceID string
|
||||
BackState bot.State
|
||||
OpenPlacements bool
|
||||
|
||||
// Поля для управления фоновой горутиной polling
|
||||
cancel context.CancelFunc
|
||||
@@ -106,8 +106,8 @@ func (s *MyProjects) renderProjects(b *bot.Bot, mode bot.RenderMode, jwt string)
|
||||
|
||||
Начните с добавления первого проекта`
|
||||
nonEmptyText := "Управление вашими Telegram-каналами.\n\nВыберите канал"
|
||||
if s.OpenPurchases {
|
||||
headerTitle = "Закупы"
|
||||
if s.OpenPlacements {
|
||||
headerTitle = "Размещения"
|
||||
nonEmptyText = "Выберите проект для просмотра закупов"
|
||||
}
|
||||
|
||||
@@ -224,12 +224,12 @@ func (s *MyProjects) HandleCallback(b *bot.Bot, u *echotron.Update) {
|
||||
return
|
||||
}
|
||||
|
||||
if s.OpenPurchases {
|
||||
b.SetState(&Purchases{
|
||||
if s.OpenPlacements {
|
||||
b.SetState(&Placements{
|
||||
WorkspaceID: s.WorkspaceID,
|
||||
ProjectID: project.ID,
|
||||
ProjectTitle: project.Title,
|
||||
BackState: &MyProjects{WorkspaceID: s.WorkspaceID, OpenPurchases: true},
|
||||
BackState: &MyProjects{WorkspaceID: s.WorkspaceID, OpenPlacements: true},
|
||||
}, bot.EditMessage)
|
||||
} else {
|
||||
b.SetState(&ProjectDetails{
|
||||
|
||||
@@ -73,10 +73,9 @@ func (s *ProjectDetails) formatProjectDetails() string {
|
||||
func (s *ProjectDetails) buildKeyboard() echotron.InlineKeyboardMarkup {
|
||||
var buttons [][]echotron.InlineKeyboardButton
|
||||
|
||||
// Первый ряд: Креативы и Закупы
|
||||
buttons = append(buttons, Row(
|
||||
Button("Креативы", fmt.Sprintf("creatives:%s", s.Project.ID)),
|
||||
Button("Закупы", fmt.Sprintf("purchases:%s", s.Project.ID)),
|
||||
Button("Размещения", fmt.Sprintf("placements:%s", s.Project.ID)),
|
||||
))
|
||||
|
||||
// Второй ряд: Тип вступления по умолчанию для закупов (с подтверждением)
|
||||
@@ -135,9 +134,9 @@ func (s *ProjectDetails) HandleCallback(b *bot.Bot, u *echotron.Update) {
|
||||
BackState: s,
|
||||
}, bot.EditMessage)
|
||||
|
||||
case strings.HasPrefix(data, "purchases:"):
|
||||
case strings.HasPrefix(data, "placements:"):
|
||||
s.confirmingLinkTypeChange = false // Сбрасываем флаг подтверждения
|
||||
b.SetState(&Purchases{
|
||||
b.SetState(&Placements{
|
||||
WorkspaceID: s.WorkspaceID,
|
||||
ProjectID: s.Project.ID,
|
||||
ProjectTitle: s.Project.Title,
|
||||
|
||||
@@ -1468,7 +1468,7 @@ func (s *PurchaseOptionalDetails) createPurchase(b *bot.Bot, jwt string) {
|
||||
}
|
||||
}
|
||||
|
||||
b.SetState(&Purchases{
|
||||
b.SetState(&Placements{
|
||||
WorkspaceID: s.WorkspaceID,
|
||||
ProjectID: s.ProjectID,
|
||||
ProjectTitle: s.ProjectTitle,
|
||||
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type Purchases struct {
|
||||
type Placements struct {
|
||||
WorkspaceID string
|
||||
ProjectID string
|
||||
ProjectTitle string
|
||||
BackState bot.State
|
||||
}
|
||||
|
||||
func (s *Purchases) Enter(b *bot.Bot, mode bot.RenderMode) {
|
||||
func (s *Placements) Enter(b *bot.Bot, mode bot.RenderMode) {
|
||||
jwt := b.Session.JWT
|
||||
if jwt == "" {
|
||||
log.Error().Msg("JWT is empty in session")
|
||||
@@ -27,7 +27,7 @@ func (s *Purchases) Enter(b *bot.Bot, mode bot.RenderMode) {
|
||||
s.renderPurchases(b, mode, jwt)
|
||||
}
|
||||
|
||||
func (s *Purchases) renderPurchases(b *bot.Bot, mode bot.RenderMode, jwt string) {
|
||||
func (s *Placements) renderPurchases(b *bot.Bot, mode bot.RenderMode, jwt string) {
|
||||
resp, err := b.Backend.GetPlacements(
|
||||
context.Background(),
|
||||
jwt,
|
||||
@@ -93,7 +93,7 @@ func (s *Purchases) renderPurchases(b *bot.Bot, mode bot.RenderMode, jwt string)
|
||||
b.Render(text, keyboard, mode)
|
||||
}
|
||||
|
||||
func (s *Purchases) HandleCallback(b *bot.Bot, u *echotron.Update) {
|
||||
func (s *Placements) HandleCallback(b *bot.Bot, u *echotron.Update) {
|
||||
if u.CallbackQuery == nil || u.CallbackQuery.Data == "" {
|
||||
return
|
||||
}
|
||||
@@ -131,8 +131,8 @@ func (s *Purchases) HandleCallback(b *bot.Bot, u *echotron.Update) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Purchases) HandleMessage(_ *bot.Bot, _ *echotron.Update) { return }
|
||||
func (s *Placements) HandleMessage(_ *bot.Bot, _ *echotron.Update) { return }
|
||||
|
||||
func (s *Purchases) Handle(_ *bot.Bot, _ *echotron.Update) { return }
|
||||
func (s *Placements) Handle(_ *bot.Bot, _ *echotron.Update) { return }
|
||||
|
||||
func (s *Purchases) Exit() {}
|
||||
func (s *Placements) Exit() {}
|
||||
|
||||
Reference in New Issue
Block a user