улучшение ui
This commit is contained in:
@@ -32,7 +32,7 @@ func (s *AddPurchase) Enter(b *bot.Bot, mode bot.RenderMode) {
|
||||
jwt := b.Session.JWT
|
||||
if jwt == "" {
|
||||
log.Error().Msg("JWT is empty in session")
|
||||
b.SendNew("❌ Ошибка авторизации. Попробуйте /start", bot.Keyboard())
|
||||
b.SendNew("❌ Ошибка авторизации. Попробуйте /start", Keyboard())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
}
|
||||
|
||||
if s.ActivePicker == "" {
|
||||
buttons = append(buttons, bot.Row(
|
||||
bot.Button(projectLabel, "pick_project"),
|
||||
buttons = append(buttons, Row(
|
||||
Button(projectLabel, "pick_project"),
|
||||
))
|
||||
buttons = append(buttons, bot.Row(
|
||||
bot.Button(creativeLabel, "pick_creative"),
|
||||
buttons = append(buttons, Row(
|
||||
Button(creativeLabel, "pick_creative"),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to get projects")
|
||||
b.SendNew("❌ Не удалось загрузить проекты", bot.Keyboard())
|
||||
b.SendNew("❌ Не удалось загрузить проекты", Keyboard())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,11 +90,11 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
|
||||
var slots []echotron.InlineKeyboardButton
|
||||
for _, project := range page.Items {
|
||||
slots = append(slots, bot.Button(project.Title, fmt.Sprintf("project:%s", project.ID)))
|
||||
slots = append(slots, Button(project.Title, fmt.Sprintf("project:%s", project.ID)))
|
||||
}
|
||||
if page.Pages >= 2 {
|
||||
for len(slots) < addPurchaseProjectsPerPage {
|
||||
slots = append(slots, bot.Button(" ", "empty"))
|
||||
slots = append(slots, Button(" ", "empty"))
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(slots); i += 2 {
|
||||
@@ -102,7 +102,7 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
if i+1 < len(slots) {
|
||||
row = append(row, slots[i+1])
|
||||
} else {
|
||||
row = append(row, bot.Button(" ", "empty"))
|
||||
row = append(row, Button(" ", "empty"))
|
||||
}
|
||||
buttons = append(buttons, row)
|
||||
}
|
||||
@@ -115,15 +115,15 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
}
|
||||
}
|
||||
|
||||
buttons = append(buttons, bot.Row(
|
||||
bot.Button("← Назад", "back_to_selection"),
|
||||
buttons = append(buttons, Row(
|
||||
Button("← Назад", "back_to_selection"),
|
||||
))
|
||||
|
||||
case "creative_list":
|
||||
if s.ProjectID == "" {
|
||||
text += "Сначала выберите проект, чтобы увидеть список креативов.\n\n"
|
||||
buttons = append(buttons, bot.Row(
|
||||
bot.Button("← Назад", "back_to_selection"),
|
||||
buttons = append(buttons, Row(
|
||||
Button("← Назад", "back_to_selection"),
|
||||
))
|
||||
break
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to get creatives")
|
||||
b.SendNew("❌ Не удалось загрузить креативы", bot.Keyboard())
|
||||
b.SendNew("❌ Не удалось загрузить креативы", Keyboard())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,11 +157,11 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
|
||||
var slots []echotron.InlineKeyboardButton
|
||||
for _, creative := range page.Items {
|
||||
slots = append(slots, bot.Button(creative.Name, fmt.Sprintf("creative:%s", creative.ID)))
|
||||
slots = append(slots, Button(creative.Name, fmt.Sprintf("creative:%s", creative.ID)))
|
||||
}
|
||||
if page.Pages >= 2 {
|
||||
for len(slots) < addPurchaseCreativesPerPage {
|
||||
slots = append(slots, bot.Button(" ", "empty"))
|
||||
slots = append(slots, Button(" ", "empty"))
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(slots); i += 2 {
|
||||
@@ -169,7 +169,7 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
if i+1 < len(slots) {
|
||||
row = append(row, slots[i+1])
|
||||
} else {
|
||||
row = append(row, bot.Button(" ", "empty"))
|
||||
row = append(row, Button(" ", "empty"))
|
||||
}
|
||||
buttons = append(buttons, row)
|
||||
}
|
||||
@@ -182,25 +182,25 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode, jwt strin
|
||||
}
|
||||
}
|
||||
|
||||
buttons = append(buttons, bot.Row(
|
||||
bot.Button("← Назад", "back_to_selection"),
|
||||
buttons = append(buttons, Row(
|
||||
Button("← Назад", "back_to_selection"),
|
||||
))
|
||||
}
|
||||
|
||||
if s.ActivePicker == "" {
|
||||
if s.ProjectID != "" && s.CreativeID != "" {
|
||||
buttons = append(buttons, bot.Row(
|
||||
bot.Button("← Отмена", "back"),
|
||||
bot.Button("→ Далее", "next"),
|
||||
buttons = append(buttons, Row(
|
||||
Button("← Отмена", "back"),
|
||||
Button("→ Далее", "next"),
|
||||
))
|
||||
} else {
|
||||
buttons = append(buttons, bot.Row(
|
||||
bot.Button("← Отмена", "back"),
|
||||
buttons = append(buttons, Row(
|
||||
Button("← Отмена", "back"),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
keyboard := bot.Keyboard(buttons...)
|
||||
keyboard := Keyboard(buttons...)
|
||||
b.Render(text, keyboard, mode)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user