PlanTempusApp/PlanTempus.Application/Features/Menu/Services/MockMenuService.cs

255 lines
8.3 KiB
C#
Raw Normal View History

2026-01-10 20:39:17 +01:00
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>
{
2026-01-14 20:57:35 +01:00
// OVERVIEW GROUP
2026-01-10 20:39:17 +01:00
new MenuGroup
{
2026-01-14 20:57:35 +01:00
Id = "overview",
2026-01-10 20:39:17 +01:00
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 = "/kalender",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Staff,
SortOrder = 2
},
new MenuItem
{
Id = "pos",
Label = "Kasse",
Icon = "ph-cash-register",
Url = "/kasse",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Staff,
SortOrder = 3
}
}
},
// QUICK ACTIONS GROUP
new MenuGroup
{
Id = "quickActions",
Label = "Hurtigvalg",
SortOrder = 2,
Items = new List<MenuItem>
{
new MenuItem
{
Id = "createBooking",
Label = "Opret booking",
Icon = "ph-calendar-plus",
Url = "/opret-booking",
MinimumRole = UserRole.Staff,
SortOrder = 1
},
new MenuItem
{
Id = "createSale",
Label = "Opret salg",
Icon = "ph-shopping-cart",
Url = "/opret-salg",
MinimumRole = UserRole.Staff,
SortOrder = 2
}
}
},
2026-01-10 20:39:17 +01:00
// DATA GROUP
new MenuGroup
{
Id = "data",
Label = "Data",
SortOrder = 3,
2026-01-10 20:39:17 +01:00
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",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Manager,
SortOrder = 2
},
new MenuItem
{
Id = "customers",
Label = "Kunder",
Icon = "ph-users",
Url = "/kunder",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Staff,
SortOrder = 3
},
new MenuItem
{
Id = "employees",
Label = "Medarbejdere",
2026-01-12 22:10:57 +01:00
Icon = "ph-users-three",
Url = "/medarbejdere",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Manager,
SortOrder = 4
},
new MenuItem
{
Id = "services",
Label = "Services",
Icon = "ph-scissors",
Url = "/services",
MinimumRole = UserRole.Manager,
SortOrder = 5
2026-01-10 20:39:17 +01:00
}
}
},
// ONLINE GROUP
new MenuGroup
{
Id = "online",
Label = "Online",
SortOrder = 4,
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
}
}
},
2026-01-10 20:39:17 +01:00
// ANALYSE GROUP
new MenuGroup
{
Id = "analytics",
Label = "Analyse",
SortOrder = 5,
2026-01-10 20:39:17 +01:00
Items = new List<MenuItem>
{
new MenuItem
{
Id = "reports",
Label = "Statistik & Rapporter",
Icon = "ph-chart-line-up",
Url = "/rapporter",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Manager,
SortOrder = 1
}
}
},
// SYSTEM GROUP
new MenuGroup
{
Id = "system",
Label = "System",
SortOrder = 6,
2026-01-10 20:39:17 +01:00
Items = new List<MenuItem>
{
new MenuItem
{
Id = "settings",
Label = "Indstillinger",
Icon = "ph-gear",
Url = "/indstillinger",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Admin,
SortOrder = 1
},
new MenuItem
{
Id = "account",
Label = "Abonnement & Konto",
Icon = "ph-credit-card",
Url = "/konto",
2026-01-10 20:39:17 +01:00
MinimumRole = UserRole.Admin,
SortOrder = 2
}
}
}
};
}
}