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