package navbar

import (
	"github.com/emarifer/go-templ-project-structure/views/component/sidebarmaster"
	"github.com/emarifer/go-templ-project-structure/services"
	"github.com/emarifer/go-templ-project-structure/models"
)

templ Navbar(dataUser models.User) {
	<div id="kt_header" class="header header-fixed ">
		<!--begin::Container-->
		<div class="container-fluid  d-flex align-items-stretch justify-content-between">
			<!--begin::Header Menu Wrapper-->
			<div class="header-menu-wrapper header-menu-wrapper-left" id="kt_header_menu_wrapper"></div>
			<!--end::Header Menu Wrapper-->
			<!--begin::Topbar-->
			<div class="topbar">
				<!--begin::User-->
				<div class="topbar-item">
					<div
						class="btn btn-icon btn-icon-mobile w-auto btn-clean d-flex align-items-center btn-lg px-2"
						id="kt_quick_user_toggle"
					>
						<span
							class="text-muted font-weight-bold font-size-base d-none d-md-inline mr-1"
						>Hi,</span>
						<span
							class="text-dark-50 font-weight-bolder font-size-base d-none d-md-inline mr-3"
						>{ dataUser.Username }</span>
						<span class="bg-primary-transparent p-3" style="border-radius: 50%; width: 40px; height: 40px;">
							<span class="iconify text-primary" data-icon="gravity-ui:person"></span>
						</span>
					</div>
				</div>
				<!--end::User-->
			</div>
			<!--end::Topbar-->
		</div>
		<!--end::Container-->
	</div>
}

templ NavbarMenu(datamenu []services.MasterMenu) {
	<div class="aside-menu-wrapper flex-column-fluid" id="kt_aside_menu_wrapper">
		<!--begin::Menu Container-->
		<div
			id="kt_aside_menu"
			class="aside-menu my-4 "
			data-menu-vertical="1"
			data-menu-scroll="1"
			data-menu-dropdown-timeout="500"
		>
			<!--begin::Menu Nav-->
			<ul class="menu-nav ">
				for index, d := range datamenu {
					if index == 0 {
						// @MenuDashboard(d.ParentMenuName, d.ParentUrl)
						@sidebarmaster.MenuDashboard(d.ParentMenuName, d.ParentUrl)
						<li class="menu-section ">
							<h4 class="menu-text">Menu</h4>
							<i class="menu-icon ki ki-bold-more-hor icon-md"></i>
						</li>
					}
					if index+1 < len(datamenu) {
						// @ListMenuNavbar(datamenu[index+1].ParentMenuName, d.Children)
						@sidebarmaster.ListMenuNavbar(datamenu[index+1].ParentMenuName, datamenu[index+1].Children)
					}
				}
			</ul>
			<!--end::Menu Nav-->
		</div>
		<!--end::Menu Container-->
	</div>
}
