package controllers

import (
	"LAPP_LF_MOM_BACKEND/utils"
	"LAPP_LF_MOM_BACKEND/web/middleware/jwts"
	"LAPP_LF_MOM_BACKEND/web/models"
	"LAPP_LF_MOM_BACKEND/web/supports"
	"github.com/kataras/iris/v12"
)

func DynamicMenu(ctx iris.Context) {
	user, ok := jwts.ParseToken(ctx)
	if !ok {
		return
	}
	utils.TrimStruct(user,*user)
	menu := new(models.Menu)
	menuTree,_ := menu.SetMenuRole(user.Role)
	supports.Ok(ctx, supports.OptionSuccess, menuTree)
}