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 FriendAssistHeroView struct {
	BaseformView
}

func (this *FriendAssistHeroView) CreateView(t *model.TestCase) fyne.CanvasObject {

	heroId := widget.NewEntry()
	heroId.PlaceHolder = "hero ObjId"

	this.form.AppendItem(widget.NewFormItem("HeroObjID", heroId))

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