package formview

import (
	"go_dreamfactory/cmd/v2/model"
	"go_dreamfactory/cmd/v2/service"
	"go_dreamfactory/pb"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/widget"
	"github.com/sirupsen/logrus"
)

type EquipUpgradeView struct {
	BaseformView
}

func (this *EquipUpgradeView) CreateView(t *model.TestCase) fyne.CanvasObject {
	equipId := widget.NewEntry()
	equipId.PlaceHolder = "装备ID"
	this.form.AppendItem(widget.NewFormItem("装备ID", equipId))

	this.form.OnSubmit = func() {
		if err := service.GetPttService().SendToClient(t.MainType, t.SubType,
			&pb.EquipmentUpgradeReq{
				EquipmentId: equipId.Text,
			}); err != nil {
			logrus.Error(err)
			return
		}
	}
	return this.form
}
