package component
import (
	"path/filepath"
	"strings"
	"management/internal/erpserver/model/dto"
	"github.com/a-h/templ"
)
func TemplBtn(buttons []dto.OwnerMenuDto, searchBtn bool, actionNames ...string) templ.Component {
	var res string
	if len(actionNames) == 0 {
		return templ.Raw(res)
	}
	if len(buttons) == 0 {
		return templ.Raw(res)
	}
	res = ``
	return templ.Raw(res)
}
func TemplLink(buttons []dto.OwnerMenuDto, actionNames ...string) templ.Component {
	var res string
	if len(actionNames) == 0 {
		return templ.Raw(res)
	}
	if len(buttons) == 0 {
		return templ.Raw(res)
	}
	res = ``
	return templ.Raw(res)
}
func GenBtn(buttons []dto.OwnerMenuDto, actionNames ...string) string {
	var res string
	if len(buttons) == 0 {
		return res
	}
	if len(actionNames) == 0 {
		return res
	}
	for _, action := range actionNames {
		for _, btn := range buttons {
			btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
			base := filepath.Base(btn.Url)
			if base == action {
				res += ``
			}
		}
	}
	return res
}
func GenLink(buttons []dto.OwnerMenuDto, actionNames ...string) string {
	if len(buttons) == 0 {
		return ""
	}
	if len(actionNames) == 0 {
		return ""
	}
	var res string
	for _, action := range actionNames {
		for _, btn := range buttons {
			btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
			base := filepath.Base(btn.Url)
			if base == action {
				res += ``
			}
		}
	}
	return res
}
func SubmitBtn(buttons []dto.OwnerMenuDto, actionNames ...string) templ.Component {
	var res string
	if len(buttons) == 0 {
		return templ.Raw(res)
	}
	if len(actionNames) == 0 {
		return templ.Raw(res)
	}
	for _, action := range actionNames {
		for _, btn := range buttons {
			btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
			base := filepath.Base(btn.Url)
			if base == action {
				res += ``
			}
		}
	}
	return templ.Raw(res)
}
func firstLower(s string) string {
	if len(s) == 0 {
		return s
	}
	return strings.ToLower(s[:1]) + s[1:]
}