71 lines
2.4 KiB
Go
71 lines
2.4 KiB
Go
package keyboard
|
||
|
||
import (
|
||
"bitrix_balancer_api/core/typescore"
|
||
"bitrix_balancer_api/telegram_service/approvalflow"
|
||
"fmt"
|
||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||
)
|
||
|
||
// BuildObserverTopicMenu — список тем для наблюдателя.
|
||
func BuildObserverTopicMenu(topics []approvalflow.Topic) tgbotapi.InlineKeyboardMarkup {
|
||
var rows [][]tgbotapi.InlineKeyboardButton
|
||
for _, t := range topics {
|
||
btn := tgbotapi.NewInlineKeyboardButtonData(
|
||
t.Name(),
|
||
fmt.Sprintf("obs_topic:%s", t.Code()),
|
||
)
|
||
rows = append(rows, tgbotapi.NewInlineKeyboardRow(btn))
|
||
}
|
||
return tgbotapi.NewInlineKeyboardMarkup(rows...)
|
||
}
|
||
|
||
// BuildObserverApprovalList — список заявок в теме (ФИО — Отдел).
|
||
func BuildObserverApprovalList(
|
||
approvals []*typescore.Approval,
|
||
initiators map[uint64]*typescore.User,
|
||
departments map[uint64]*typescore.Department,
|
||
topicCode string,
|
||
) tgbotapi.InlineKeyboardMarkup {
|
||
var rows [][]tgbotapi.InlineKeyboardButton
|
||
for _, a := range approvals {
|
||
if a.ID == nil {
|
||
continue
|
||
}
|
||
label := fmt.Sprintf("#%d", *a.ID)
|
||
if a.InitiatorID != nil {
|
||
if u, ok := initiators[*a.InitiatorID]; ok && u.FullName != nil {
|
||
label += " " + *u.FullName
|
||
}
|
||
}
|
||
if a.DepartmentID != nil {
|
||
if d, ok := departments[*a.DepartmentID]; ok && d.Name != nil {
|
||
label += " — " + *d.Name
|
||
}
|
||
}
|
||
rows = append(rows, tgbotapi.NewInlineKeyboardRow(
|
||
tgbotapi.NewInlineKeyboardButtonData(label, fmt.Sprintf("obs_approval:%d", *a.ID)),
|
||
))
|
||
}
|
||
rows = append(rows, tgbotapi.NewInlineKeyboardRow(
|
||
tgbotapi.NewInlineKeyboardButtonData("🔙 К темам", "obs_back_topics"),
|
||
))
|
||
return tgbotapi.NewInlineKeyboardMarkup(rows...)
|
||
}
|
||
|
||
// BuildObserverApprovalDetail — карточка заявки с кнопками наблюдателя.
|
||
func BuildObserverApprovalDetail(approvalID uint64, topicCode string) tgbotapi.InlineKeyboardMarkup {
|
||
return tgbotapi.NewInlineKeyboardMarkup(
|
||
tgbotapi.NewInlineKeyboardRow(
|
||
tgbotapi.NewInlineKeyboardButtonData("🔔 Напомнить согласующему", fmt.Sprintf("obs_remind:%d", approvalID)),
|
||
tgbotapi.NewInlineKeyboardButtonData("💬 Добавить комментарий", fmt.Sprintf("appr_comment:%d", approvalID)),
|
||
),
|
||
tgbotapi.NewInlineKeyboardRow(
|
||
tgbotapi.NewInlineKeyboardButtonData(
|
||
"🔙 Назад к списку",
|
||
fmt.Sprintf("obs_back:%s", topicCode),
|
||
),
|
||
),
|
||
)
|
||
}
|