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
17 changes: 13 additions & 4 deletions src/app/milestones/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export default async function MilestonesPage() {

<div className="mt-8 grid gap-4 md:grid-cols-2">
{milestones.map((m) => {
const pct = m.distributed / m.budget;
const hasBudget = m.budget > 0;
const pct = hasBudget ? m.distributed / m.budget : 0;
const isOverDistributed = hasBudget && m.distributed > m.budget;
const clampedPct = Math.min(pct, 1);
return (
<div
key={m.id}
Expand All @@ -37,16 +40,22 @@ export default async function MilestonesPage() {
<h3 className="mt-1 font-medium text-slate-900 dark:text-white">{m.name}</h3>
<div className="mt-4 h-2 w-full overflow-hidden rounded-full bg-slate-100 dark:bg-slate-800">
<div
className="h-full bg-indigo-600"
style={{ width: `${Math.min(pct * 100, 100)}%` }}
className={`h-full ${isOverDistributed ? "bg-amber-500" : "bg-indigo-600"}`}
style={{ width: `${clampedPct * 100}%` }}
/>
</div>
<div className="mt-3 flex items-center justify-between text-sm text-slate-500 dark:text-slate-400">
<span>
{formatCurrency(m.distributed, m.asset)} of{" "}
{formatCurrency(m.budget, m.asset)}
</span>
<span>{formatPercent(pct)}</span>
<span>
{!hasBudget
? "Not yet funded"
: isOverDistributed
? `${formatPercent(pct)} (over-distributed)`
: formatPercent(clampedPct)}
</span>
</div>
<p className="mt-2 text-xs text-slate-400 dark:text-slate-500">
{m.completedCount} of {m.issueCount} issues complete
Expand Down