Skip to content
Merged
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
19 changes: 13 additions & 6 deletions src/components/DeadlineCountdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function DeadlineCountdown({ lastPlotTime }: { lastPlotTime: string }) {
return (
<div className="border-border bg-surface mt-4 rounded border px-3 py-2 text-xs">
<span className="text-muted">Next plot due in </span>
<span className="text-accent font-medium">--:--:--</span>
<span className="text-accent font-medium">--</span>
</div>
);
}
Expand All @@ -33,17 +33,24 @@ export function DeadlineCountdown({ lastPlotTime }: { lastPlotTime: string }) {
);
}

const hours = Math.floor(remaining / 3600);
const days = Math.floor(remaining / 86400);
const hours = Math.floor((remaining % 86400) / 3600);
const minutes = Math.floor((remaining % 3600) / 60);
const seconds = remaining % 60;

let formatted: string;
if (days > 0) {
formatted = `${days}d ${hours}h ${minutes}m ${seconds}s`;
} else if (hours > 0) {
formatted = `${hours}h ${minutes}m ${seconds}s`;
} else {
formatted = `${minutes}m ${seconds}s`;
}

return (
<div className="border-border bg-surface mt-4 rounded border px-3 py-2 text-xs">
<span className="text-muted">Next plot due in </span>
<span className="text-accent font-medium">
{String(hours).padStart(2, "0")}:{String(minutes).padStart(2, "0")}:
{String(seconds).padStart(2, "0")}
</span>
<span className="text-accent font-medium">{formatted}</span>
</div>
);
}
Expand Down
Loading