PlanTempusApp/PlanTempus.Application/Features/Menu/Services/MockMenuService.cs
Janus C. H. Knudsen eba6bd646d Adds Online group to application menu and localization
Introduces new menu group with Booking and Website sections
Updates Danish localization to include new menu items and group

Enhances application navigation with online-related features
2026-01-25 19:21:51 +01:00

225 lines
7.4 KiB
C#

using PlanTempus.Application.Features.Localization.Services;
using PlanTempus.Application.Features.Menu.Models;
namespace PlanTempus.Application.Features.Menu.Services;
/// <summary>
/// Mock implementation of IMenuService with hardcoded menu data.
/// </summary>
public class MockMenuService : IMenuService
{
private readonly ILocalizationService _localize;
public MockMenuService(ILocalizationService localize)
{
_localize = localize;
}
public List<MenuGroup> GetMenuForRole(UserRole role, string? currentUrl = null)
{
var allGroups = GetAllMenuGroups();
return allGroups
.Select(g => new MenuGroup
{
Id = g.Id,
Label = _localize.Get($"groups.{g.Id}"),
SortOrder = g.SortOrder,
Items = g.Items
.Where(i => role >= i.MinimumRole)
.Select(i => new MenuItem
{
Id = i.Id,
Label = _localize.Get($"menu.{i.Id}"),
Icon = i.Icon,
Url = i.Url,
MinimumRole = i.MinimumRole,
SortOrder = i.SortOrder,
IsActive = currentUrl != null && i.Url.Equals(currentUrl, StringComparison.OrdinalIgnoreCase)
})
.OrderBy(i => i.SortOrder)
.ToList()
})
.Where(g => g.Items.Any())
.OrderBy(g => g.SortOrder)
.ToList();
}
private static List<MenuGroup> GetAllMenuGroups()
{
return new List<MenuGroup>
{
// OVERVIEW GROUP
new MenuGroup
{
Id = "overview",
Label = "Dashboard",
SortOrder = 1,
Items = new List<MenuItem>
{
new MenuItem
{
Id = "home",
Label = "Dashboard",
Icon = "ph-squares-four",
Url = "/",
MinimumRole = UserRole.Staff,
SortOrder = 1
},
new MenuItem
{
Id = "calendar",
Label = "Kalender",
Icon = "ph-calendar",
Url = "/poc-calendar.html",
MinimumRole = UserRole.Staff,
SortOrder = 2
},
new MenuItem
{
Id = "pos",
Label = "Kasse",
Icon = "ph-cash-register",
Url = "/kasse",
MinimumRole = UserRole.Staff,
SortOrder = 3
}
}
},
// DATA GROUP
new MenuGroup
{
Id = "data",
Label = "Data",
SortOrder = 2,
Items = new List<MenuItem>
{
new MenuItem
{
Id = "products",
Label = "Produkter & Lager",
Icon = "ph-package",
Url = "/poc-produkter.html",
MinimumRole = UserRole.Manager,
SortOrder = 1
},
new MenuItem
{
Id = "suppliers",
Label = "Leverandører",
Icon = "ph-truck",
Url = "/leverandoerer",
MinimumRole = UserRole.Manager,
SortOrder = 2
},
new MenuItem
{
Id = "customers",
Label = "Kunder",
Icon = "ph-users",
Url = "/kunder",
MinimumRole = UserRole.Staff,
SortOrder = 3
},
new MenuItem
{
Id = "employees",
Label = "Medarbejdere",
Icon = "ph-users-three",
Url = "/medarbejdere",
MinimumRole = UserRole.Manager,
SortOrder = 4
},
new MenuItem
{
Id = "services",
Label = "Services",
Icon = "ph-scissors",
Url = "/services",
MinimumRole = UserRole.Manager,
SortOrder = 5
}
}
},
// ONLINE GROUP
new MenuGroup
{
Id = "online",
Label = "Online",
SortOrder = 3,
Items = new List<MenuItem>
{
new MenuItem
{
Id = "booking",
Label = "Booking",
Icon = "ph-calendar-check",
Url = "/online-booking",
MinimumRole = UserRole.Manager,
SortOrder = 1
},
new MenuItem
{
Id = "website",
Label = "Website",
Icon = "ph-globe",
Url = "/website",
MinimumRole = UserRole.Manager,
SortOrder = 2
}
}
},
// ANALYSE GROUP
new MenuGroup
{
Id = "analytics",
Label = "Analyse",
SortOrder = 4,
Items = new List<MenuItem>
{
new MenuItem
{
Id = "reports",
Label = "Statistik & Rapporter",
Icon = "ph-chart-line-up",
Url = "/rapporter",
MinimumRole = UserRole.Manager,
SortOrder = 1
}
}
},
// SYSTEM GROUP
new MenuGroup
{
Id = "system",
Label = "System",
SortOrder = 5,
Items = new List<MenuItem>
{
new MenuItem
{
Id = "settings",
Label = "Indstillinger",
Icon = "ph-gear",
Url = "/indstillinger",
MinimumRole = UserRole.Admin,
SortOrder = 1
},
new MenuItem
{
Id = "account",
Label = "Abonnement & Konto",
Icon = "ph-credit-card",
Url = "/konto",
MinimumRole = UserRole.Admin,
SortOrder = 2
}
}
}
};
}
}