refactor + fix добавление проекта
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/NicoNex/echotron/v3"
|
||||
"github.com/TelegramExchange/tgex-backend/tg_bot/backend"
|
||||
"github.com/TelegramExchange/tgex-backend/tg_bot/bot"
|
||||
"github.com/TelegramExchange/tgex-backend/tg_bot/screens/ui"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -96,24 +97,15 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode) {
|
||||
} else {
|
||||
text += fmt.Sprintf("Проекты%s\n\n", ui.FormatPageInfo(s.ProjectPage, page.Pages))
|
||||
|
||||
var slots []echotron.InlineKeyboardButton
|
||||
for _, project := range page.Items {
|
||||
slots = append(slots, Button(project.Title, fmt.Sprintf("project:%s", project.ID)))
|
||||
}
|
||||
if page.Pages >= 2 {
|
||||
for len(slots) < addPurchaseProjectsPerPage {
|
||||
slots = append(slots, Button(" ", "empty"))
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(slots); i += 2 {
|
||||
row := []echotron.InlineKeyboardButton{slots[i]}
|
||||
if i+1 < len(slots) {
|
||||
row = append(row, slots[i+1])
|
||||
} else {
|
||||
row = append(row, Button(" ", "empty"))
|
||||
}
|
||||
buttons = append(buttons, row)
|
||||
}
|
||||
buttons = append(buttons, ui.BuildGrid(
|
||||
page.Items,
|
||||
2,
|
||||
addPurchaseProjectsPerPage,
|
||||
page.Pages,
|
||||
func(project backend.Project) (string, string) {
|
||||
return project.Title, "project:" + project.ID
|
||||
},
|
||||
)...)
|
||||
|
||||
if navRow := ui.BuildNavigationRow(ui.PaginationConfig{
|
||||
CurrentPage: s.ProjectPage,
|
||||
@@ -157,24 +149,15 @@ func (s *AddPurchase) renderSelection(b *bot.Bot, mode bot.RenderMode) {
|
||||
} else {
|
||||
text += fmt.Sprintf("Креативы%s\n\n", ui.FormatPageInfo(s.CreativePage, page.Pages))
|
||||
|
||||
var slots []echotron.InlineKeyboardButton
|
||||
for _, creative := range page.Items {
|
||||
slots = append(slots, Button(creative.Name, fmt.Sprintf("creative:%s", creative.ID)))
|
||||
}
|
||||
if page.Pages >= 2 {
|
||||
for len(slots) < addPurchaseCreativesPerPage {
|
||||
slots = append(slots, Button(" ", "empty"))
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(slots); i += 2 {
|
||||
row := []echotron.InlineKeyboardButton{slots[i]}
|
||||
if i+1 < len(slots) {
|
||||
row = append(row, slots[i+1])
|
||||
} else {
|
||||
row = append(row, Button(" ", "empty"))
|
||||
}
|
||||
buttons = append(buttons, row)
|
||||
}
|
||||
buttons = append(buttons, ui.BuildGrid(
|
||||
page.Items,
|
||||
2,
|
||||
addPurchaseCreativesPerPage,
|
||||
page.Pages,
|
||||
func(creative backend.Creative) (string, string) {
|
||||
return creative.Name, "creative:" + creative.ID
|
||||
},
|
||||
)...)
|
||||
|
||||
if navRow := ui.BuildNavigationRow(ui.PaginationConfig{
|
||||
CurrentPage: s.CreativePage,
|
||||
|
||||
Reference in New Issue
Block a user