package public_handlers

import (
	"cpone/models"
	"cpone/utils"
	"cpone/views/dev/mastermenuusergroup"

	tablecomponent "cpone/component/table"

	public_toast "cpone/views/public/toast"

	"github.com/labstack/echo/v4"
)

type ToolsService interface {
}

func NewToolsHandler(us ToolsService) *ToolsHandler {
	return &ToolsHandler{
		ToolsService: us,
	}
}

type ToolsHandler struct {
	ToolsService ToolsService
}

func (lh *ToolsHandler) HandlerHideToast(c echo.Context) error {
	toastComponent := public_toast.PublicToastV1Hide()

	si := toastComponent

	return utils.View(c, si)
}

func (lh *ToolsHandler) HandlerShowToast(c echo.Context) error {

	inputansearchComponent := tablecomponent.DivEmpty()
	// toastComponent := public_toast.PublicToastV1Show("Success", "Success Loaded", "success")
	pagination := tablecomponent.DivEmpty()

	dummyData := []models.UserGroupV1{
		{
			Nomor:                  "1",
			M_UserGroupID:          1,
			M_UserGroupCode:        "group1",
			M_UserGroupName:        "Group 1",
			M_UserGroupCreated:     "2024-05-16",
			M_UserGroupLastUpdated: "2024-05-16",
			M_UserGroupIsActive:    "Active",
		},
	}

	tabelusergroupComponent := tablecomponent.TableV2(
		[]string{"KODE", "USERGROUP", "AKSI"},
		[]string{"40%", "40%", "20%"},
		mastermenuusergroup.TableRowV1(dummyData, "", "", "", "", "", "", "", ""),
		pagination,
		"",
		inputansearchComponent,
	)

	si := public_toast.ShowToast("",
		tabelusergroupComponent,
		tabelusergroupComponent,
		tabelusergroupComponent,
		tabelusergroupComponent,
		tabelusergroupComponent,
		tabelusergroupComponent,
	)

	return utils.View(c, si)
}
