This commit is contained in:
Artem Tsyrulnikov
2026-01-09 13:41:04 +03:00
parent a0b12dbcca
commit 6ec26c96e3
13 changed files with 164 additions and 211 deletions

View File

@@ -70,8 +70,7 @@ func (s *PurchaseOptionalDetails) Enter(b *bot.Bot, mode bot.RenderMode) {
return
}
text := "<i>… Создание Дополнительно</i>\n\n"
text += "<b>Страница создания закупа и необязательные составляющие</b>"
text := "<b>Страница создания закупа и необязательные составляющие</b>"
text += "\n\n"
text += s.formatOptionalSummary()
@@ -129,7 +128,7 @@ func (s *PurchaseOptionalDetails) HandleCallback(b *bot.Bot, u *echotron.Update)
}
case "opt_payment_date":
b.SetState(NewDateTimePicker(DateTimePickerConfig{
b.SetState(ui.NewDateTimePicker(ui.DateTimePickerConfig{
Title: "Дата оплаты",
Key: "payment_date",
IncludeTime: true,
@@ -380,8 +379,8 @@ func (s *PurchaseOptionalDetails) formatDateTime(value *time.Time) string {
if value == nil {
return "—"
}
local := value.In(mskLocation)
return fmt.Sprintf("%s %02d %s %s", weekdayName(local.Weekday()), local.Day(), monthShort(local.Month()), local.Format("15:04"))
local := value.In(ui.MskLocation)
return fmt.Sprintf("%s %02d %s %s", ui.WeekdayName(local.Weekday()), local.Day(), ui.MonthShort(local.Month()), local.Format("15:04"))
}
func (s *PurchaseOptionalDetails) formatText(value string) string {
@@ -500,7 +499,7 @@ func (s *PurchaseOptionalDetails) costBeforeDeleteRow() []echotron.InlineKeyboar
}
func (s *PurchaseOptionalDetails) renderInputPrompt(b *bot.Bot, mode bot.RenderMode) {
text := "<i>… Создание Дополнительно</i>\n\n"
text := "<b>Дополнительно</b>\n\n"
switch s.InputMode {
case "type":
text += "<b>Выберите тип закупа</b>"
@@ -598,8 +597,7 @@ func (s *PurchaseOptionalDetails) renderInputPrompt(b *bot.Bot, mode bot.RenderM
}
func (s *PurchaseOptionalDetails) renderModeSelect(b *bot.Bot, mode bot.RenderMode) {
text := "<i>… Создание Дополнительно Выбор режима</i>\n\n"
text += "<b>⚙ Переключить режим параметра</b>\n\n"
text := "<b>⚙ Переключить режим параметра</b>\n\n"
// Показываем текущую информацию о параметрах
text += s.formatOptionalSummary()
@@ -671,8 +669,7 @@ func (s *PurchaseOptionalDetails) renderParamScreens(b *bot.Bot, mode bot.Render
func (s *PurchaseOptionalDetails) renderParamChannels(b *bot.Bot, mode bot.RenderMode, param string) {
s.CurrentParam = param
text := "<i>… Создание Дополнительно</i>\n\n"
text += fmt.Sprintf("<b>%s — по каналам</b>\n\n", s.paramTitle(param))
text := fmt.Sprintf("<b>%s — по каналам</b>\n\n", s.paramTitle(param))
text += s.renderParamChannelSummary(param) + "\n\n"
const perPage = 5
@@ -866,7 +863,10 @@ func (s *PurchaseOptionalDetails) parseParamIndex(data, prefix string) (string,
return "", 0, false
}
param := parts[0]
index := parseInt(parts[1])
index, err := strconv.Atoi(parts[1])
if err != nil {
return "", 0, false
}
return param, index, true
}
@@ -875,7 +875,7 @@ func (s *PurchaseOptionalDetails) openCommonEditor(b *bot.Bot, param string) {
case "placement":
s.InputMode = ""
s.ReturnMode = ""
b.SetState(NewDateTimePicker(DateTimePickerConfig{
b.SetState(ui.NewDateTimePicker(ui.DateTimePickerConfig{
Title: "Дата и время размещения",
Key: "placement_datetime",
IncludeTime: true,
@@ -907,7 +907,7 @@ func (s *PurchaseOptionalDetails) openChannelEditor(b *bot.Bot, param, username
switch param {
case "placement":
s.InputMode = "placement_channels"
b.SetState(NewDateTimePicker(DateTimePickerConfig{
b.SetState(ui.NewDateTimePicker(ui.DateTimePickerConfig{
Title: "Дата и время размещения",
Key: "placement_datetime:" + username,
IncludeTime: true,
@@ -968,7 +968,7 @@ func (s *PurchaseOptionalDetails) pasteParamValue(param, username string) {
s.PlacementByChannel[username] = nil
return
}
value := s.PlacementCopy.In(mskLocation)
value := s.PlacementCopy.In(ui.MskLocation)
s.PlacementByChannel[username] = &value
case "cost":
if s.CostCopy == nil {
@@ -1467,11 +1467,10 @@ func (s *PurchaseOptionalDetails) createPurchase(b *bot.Bot, jwt string) {
}
b.SetState(&PurchaseDetails{
WorkspaceID: s.WorkspaceID,
ProjectID: s.ProjectID,
ProjectTitle: s.ProjectTitle,
PurchaseID: purchase.ID,
BackState: s.BackState,
WorkspaceID: s.WorkspaceID,
ProjectID: s.ProjectID,
PurchaseID: purchase.ID,
BackState: s.BackState,
}, bot.NewMessage)
}