Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/views/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1873,11 +1873,10 @@ function renderOnFireBanner(failing: number): string {
}

function renderDashboardHero(
domains: DashboardDomain[],
stats: PortfolioStats,
worst: DashboardDomain | null,
portfolioTrend: number[],
): string {
const stats = portfolioStats(domains);
const worst = worstDomain(domains);
// Mood comes from the worst *graded* domain. With nothing scored yet there
// is no signal to react to, so DMarcus defaults to neutral rather than
// panicking at a freshly-added entry that just hasn't been scanned.
Expand Down Expand Up @@ -1978,8 +1977,7 @@ function renderAddDomainWizardShell(): string {
</div>`;
}

function renderDashboardStatStrip(domains: DashboardDomain[]): string {
const stats = portfolioStats(domains);
function renderDashboardStatStrip(stats: PortfolioStats): string {
const totalCard = statCard(
"Domains",
stats.total,
Expand Down Expand Up @@ -2040,18 +2038,16 @@ export function renderDashboardPage({
isFirstRun?: boolean;
}): string {
const stats = portfolioStats(domains);
const worst = worstDomain(domains);
const banners: string[] = [];
if (plan === "free") banners.push(renderFreeTierBanner());
if (isFirstRun && domains.length === 1) {
banners.push(renderFirstRunBanner(domains[0].domain));
}
if (stats.failing >= 3) banners.push(renderOnFireBanner(stats.failing));

const hero =
domains.length > 0
? renderDashboardHero(domains, portfolioTrend)
: renderDashboardHero([], []);
const statStrip = domains.length > 0 ? renderDashboardStatStrip(domains) : "";
const hero = renderDashboardHero(stats, worst, portfolioTrend);
const statStrip = domains.length > 0 ? renderDashboardStatStrip(stats) : "";

return dashboardPage(
"Domains β€” dmarc.mx",
Expand Down