WIP
This commit is contained in:
parent
54b057886c
commit
7fc1ae0650
204 changed files with 4345 additions and 134 deletions
|
|
@ -0,0 +1,36 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlanTempus.Application.Features.Menu.Services;
|
||||
using PlanTempus.Application.Features.Menu;
|
||||
using PlanTempus.Application.Features.Menu.Models;
|
||||
|
||||
namespace PlanTempus.Application.Features.Menu;
|
||||
|
||||
/// <summary>
|
||||
/// ViewComponent for rendering the side menu based on user role.
|
||||
/// </summary>
|
||||
public class SideMenuViewComponent : ViewComponent
|
||||
{
|
||||
private readonly IMenuService _menuService;
|
||||
|
||||
public SideMenuViewComponent(IMenuService menuService)
|
||||
{
|
||||
_menuService = menuService;
|
||||
}
|
||||
|
||||
public IViewComponentResult Invoke(UserRole? role = null)
|
||||
{
|
||||
// Default to Admin for demo (in real app, get from auth)
|
||||
var userRole = role ?? UserRole.Admin;
|
||||
|
||||
var currentUrl = HttpContext.Request.Path.Value;
|
||||
var groups = _menuService.GetMenuForRole(userRole, currentUrl);
|
||||
|
||||
var viewModel = new SideMenuViewModel
|
||||
{
|
||||
Groups = groups,
|
||||
CurrentUserRole = userRole
|
||||
};
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue