navbar from services

This commit is contained in:
sindhu
2024-05-02 09:44:32 +07:00
parent 62d7735ee1
commit d7d85442e3
9 changed files with 8501 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package handlers
import (
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
mastermenu "github.com/emarifer/go-templ-project-structure/views/mastermenu"
"github.com/labstack/echo/v4"
)
type MasterMenuService interface {
GetMasterMenus() ([]services.MasterMenu, error)
}
func NewMasterMenuHandler(us MasterMenuService) *MasterMenuHandler {
return &MasterMenuHandler{
MasterMenuService: us,
}
}
type MasterMenuHandler struct {
MasterMenuService MasterMenuService
}
func (lh *MasterMenuHandler) HandlerShowMasterMenu(c echo.Context) error {
dataMenu, err := lh.MasterMenuService.GetMasterMenus()
if err != nil {
// fmt.Println(err)
return err
}
si := mastermenu.ShowMasterMenu("Master Menu",
mastermenu.MainMasterMenu(dataMenu),
mastermenu.CssMasterMenu(),
mastermenu.JsMasterMenu(),
)
return lh.View(c, si)
}
func (uh *MasterMenuHandler) View(c echo.Context, cmp templ.Component) error {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
return cmp.Render(c.Request().Context(), c.Response().Writer)
}

View File

@@ -20,8 +20,10 @@ func SetupRoutesXsample(app *echo.Echo, h *XsampleHandler) {
xSample.GET("/xsample01", h.Hello)
}
func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler) {
mastermenuHandler := &MasterMenuHandler{}
Lp := app.Group("/landing_page")
Lp.GET("/", h.ShowLandingPage)
Lp.GET("/mastermenu", mastermenuHandler.HandlerShowMasterMenu)
}
func SetupRoutesPieChart(app *echo.Echo, h *PiechartHandler) {
Lp := app.Group("/pie_chart")