diff --git a/src/routes/home.tsx b/src/routes/home.tsx index b683630..5dd862a 100644 --- a/src/routes/home.tsx +++ b/src/routes/home.tsx @@ -50,6 +50,10 @@ function tierPercent(used: number, total: number): number { return Math.round((used / total) * 100); } +function formatBytesOrDash(bytes?: number): string { + return bytes === undefined ? "—" : formatBytes(bytes); +} + type Tone = "success" | "danger"; type StatProps = { @@ -90,10 +94,14 @@ export async function handle(c: Context<{ Bindings: Env }>): Promise { ? (stats.emails_received / stats.feeds_created).toFixed(1) : "—"; - const kvBytes = stats.kv_bytes_estimated; - const kvPercent = tierPercent(kvBytes ?? 0, KV_FREE_TIER_BYTES); - const r2Bytes = stats.attachments_bytes; - const r2Percent = tierPercent(r2Bytes ?? 0, R2_FREE_TIER_BYTES); + const kvPercent = tierPercent( + stats.kv_bytes_estimated ?? 0, + KV_FREE_TIER_BYTES, + ); + const r2Percent = tierPercent( + stats.attachments_bytes ?? 0, + R2_FREE_TIER_BYTES, + ); return c.html( @@ -184,7 +192,7 @@ export async function handle(c: Context<{ Bindings: Env }>): Promise {
= 80 ? "danger" : undefined} /> @@ -196,7 +204,7 @@ export async function handle(c: Context<{ Bindings: Env }>): Promise { /> = 80 ? "danger" : undefined} />