diff --git a/src/PowderCoating.Web/Controllers/DashboardController.cs b/src/PowderCoating.Web/Controllers/DashboardController.cs index 0d5ee54..08ffb93 100644 --- a/src/PowderCoating.Web/Controllers/DashboardController.cs +++ b/src/PowderCoating.Web/Controllers/DashboardController.cs @@ -24,6 +24,7 @@ public class DashboardController : Controller private readonly ITenantContext _tenantContext; private readonly ICompanyConfigHealthService _configHealth; private readonly UserManager _userManager; + private readonly ISubscriptionService _subscriptionService; private static readonly string[] CompletedStatusCodes = [ @@ -51,7 +52,8 @@ public class DashboardController : Controller IDashboardReadService dashboardRead, ITenantContext tenantContext, ICompanyConfigHealthService configHealth, - UserManager userManager) + UserManager userManager, + ISubscriptionService subscriptionService) { _unitOfWork = unitOfWork; _logger = logger; @@ -59,6 +61,7 @@ public class DashboardController : Controller _tenantContext = tenantContext; _configHealth = configHealth; _userManager = userManager; + _subscriptionService = subscriptionService; } /// @@ -695,8 +698,10 @@ public class DashboardController : Controller var hasCustomizedLookups = await _unitOfWork.JobStatusLookups.AnyAsync(j => j.UpdatedAt != null); var teamCount = await _userManager.Users .CountAsync(u => u.CompanyId == companyId && u.IsActive && !u.IsBanned); + var (_, maxUsers) = await _subscriptionService.GetUserCountAsync(companyId); + var planAllowsMultipleUsers = maxUsers != 1; - var items = new List + var items = new List { new() { @@ -728,7 +733,7 @@ public class DashboardController : Controller CtaText = "Create invoice", CtaUrl = Url.Action("Create", "Invoices")! }, - new() + planAllowsMultipleUsers ? new() { Done = teamCount > 1, Label = "Bring your crew in", @@ -737,7 +742,7 @@ public class DashboardController : Controller Icon = "bi-people", CtaText = "Invite team", CtaUrl = Url.Action("Index", "CompanyUsers")! - }, + } : null!, new() { Done = hasCustomizedLookups, @@ -763,7 +768,7 @@ public class DashboardController : Controller } }; - return new ShopProgressWidgetViewModel { Items = items }; + return new ShopProgressWidgetViewModel { Items = items.Where(i => i != null).Select(i => i!).ToList() }; } ///