Hide team invite step on progress widget for single-user plans

Injects ISubscriptionService into DashboardController and calls
GetUserCountAsync to check the plan's MaxUsers limit. When MaxUsers == 1
the "Bring your crew in" step is omitted from the progress widget entirely,
so solo-plan users aren't prompted to do something their subscription
doesn't allow. Plans with MaxUsers > 1 or unlimited (-1) show the step
as before.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-28 21:22:41 -04:00
parent b1337d3b61
commit 64e9abceac
@@ -24,6 +24,7 @@ public class DashboardController : Controller
private readonly ITenantContext _tenantContext; private readonly ITenantContext _tenantContext;
private readonly ICompanyConfigHealthService _configHealth; private readonly ICompanyConfigHealthService _configHealth;
private readonly UserManager<ApplicationUser> _userManager; private readonly UserManager<ApplicationUser> _userManager;
private readonly ISubscriptionService _subscriptionService;
private static readonly string[] CompletedStatusCodes = private static readonly string[] CompletedStatusCodes =
[ [
@@ -51,7 +52,8 @@ public class DashboardController : Controller
IDashboardReadService dashboardRead, IDashboardReadService dashboardRead,
ITenantContext tenantContext, ITenantContext tenantContext,
ICompanyConfigHealthService configHealth, ICompanyConfigHealthService configHealth,
UserManager<ApplicationUser> userManager) UserManager<ApplicationUser> userManager,
ISubscriptionService subscriptionService)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_logger = logger; _logger = logger;
@@ -59,6 +61,7 @@ public class DashboardController : Controller
_tenantContext = tenantContext; _tenantContext = tenantContext;
_configHealth = configHealth; _configHealth = configHealth;
_userManager = userManager; _userManager = userManager;
_subscriptionService = subscriptionService;
} }
/// <summary> /// <summary>
@@ -695,8 +698,10 @@ public class DashboardController : Controller
var hasCustomizedLookups = await _unitOfWork.JobStatusLookups.AnyAsync(j => j.UpdatedAt != null); var hasCustomizedLookups = await _unitOfWork.JobStatusLookups.AnyAsync(j => j.UpdatedAt != null);
var teamCount = await _userManager.Users var teamCount = await _userManager.Users
.CountAsync(u => u.CompanyId == companyId && u.IsActive && !u.IsBanned); .CountAsync(u => u.CompanyId == companyId && u.IsActive && !u.IsBanned);
var (_, maxUsers) = await _subscriptionService.GetUserCountAsync(companyId);
var planAllowsMultipleUsers = maxUsers != 1;
var items = new List<ShopProgressItem> var items = new List<ShopProgressItem?>
{ {
new() new()
{ {
@@ -728,7 +733,7 @@ public class DashboardController : Controller
CtaText = "Create invoice", CtaText = "Create invoice",
CtaUrl = Url.Action("Create", "Invoices")! CtaUrl = Url.Action("Create", "Invoices")!
}, },
new() planAllowsMultipleUsers ? new()
{ {
Done = teamCount > 1, Done = teamCount > 1,
Label = "Bring your crew in", Label = "Bring your crew in",
@@ -737,7 +742,7 @@ public class DashboardController : Controller
Icon = "bi-people", Icon = "bi-people",
CtaText = "Invite team", CtaText = "Invite team",
CtaUrl = Url.Action("Index", "CompanyUsers")! CtaUrl = Url.Action("Index", "CompanyUsers")!
}, } : null!,
new() new()
{ {
Done = hasCustomizedLookups, 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() };
} }
/// <summary> /// <summary>