PlanTempusApp/PlanTempus.Application/Features/Menu/Services/MockMenuService.cs
Janus C. H. Knudsen 51f3b92d69 Enhances application menu and adds calendar feature
Adds new calendar page and module with comprehensive initialization

Introduces quick actions group in side menu with create booking and sale options
Updates menu service to include new menu groups and rearrange sort order
Configures custom npm registry and esbuild configuration
Adds localization for new menu items and calendar section

Implements calendar controller with dependency injection and settings seeding
2026-02-02 22:42:18 +01:00

254 lines
8.3 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 = "/kalender",
MinimumRole = UserRole.Staff,
SortOrder = 2
},
new MenuItem
{
Id = "pos",
Label = "Kasse",
Icon = "ph-cash-register",
Url = "/kasse",
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
}
}
},
// DATA GROUP
new MenuGroup
{
Id = "data",
Label = "Data",
SortOrder = 3,
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 = 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
}
}
},
// ANALYSE GROUP
new MenuGroup
{
Id = "analytics",
Label = "Analyse",
SortOrder = 5,
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 = 6,
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
}
}
}
};
}
}