fix: CycleTransferStats display

This commit is contained in:
hamster1963
2024-11-30 22:58:52 +08:00
parent 1ae404ae84
commit 1970248ae6
5 changed files with 52 additions and 47 deletions

View File

@@ -1,6 +1,7 @@
import React from "react";
import { cn } from "@/lib/utils";
import { formatBytes } from "@/lib/format";
import AnimatedCircularProgressBar from "./ui/animated-circular-progress-bar";
interface CycleTransferStatsClientProps {
name: string;
@@ -27,25 +28,36 @@ export const CycleTransferStatsClient: React.FC<
)}
>
<div className="space-y-1">
{/* <div className="flex justify-between items-center">
<span className=" font-semibold text-sm">{name}</span>
<span className="text-stone-600 dark:text-stone-400 text-xs">
{new Date(from).toLocaleDateString()} -{" "}
{new Date(to).toLocaleDateString()}
</span>
</div> */}
<div className="space-y-2">
{serverStats.map(({ serverId, serverName, transfer, nextUpdate }) => {
const progress = (transfer / max) * 100;
return (
<div key={serverId} className="space-y-2">
<div className="flex justify-between items-center">
<span className="text-sm font-semibold">{serverName}</span>
<span className="text-sm text-stone-600 dark:text-stone-400 font-semibold">
{formatBytes(transfer)} / {formatBytes(max)}
<section className="flex justify-between items-center">
<div className=" bg-blue-600 w-fit text-white px-1 py-0.5 rounded text-[10px]">
{name}
</div>
<span className="text-stone-600 dark:text-stone-400 text-xs">
{new Date(from).toLocaleDateString()} -{" "}
{new Date(to).toLocaleDateString()}
</span>
</div>
</section>
<section className="flex justify-between items-center">
<span className="text-sm font-semibold">{serverName}</span>
<div className="flex items-center gap-1">
<p className="text-xs text-end w-10 font-medium">
{progress.toFixed(0)}%
</p>
<AnimatedCircularProgressBar
className="size-4 text-[0px]"
max={100}
min={0}
value={progress}
primaryColor="hsl(var(--chart-1))"
/>
</div>
</section>
<div className="w-full bg-neutral-200 dark:bg-neutral-800 rounded-full h-2.5">
<div
className="bg-blue-600 h-2.5 rounded-full"
@@ -57,15 +69,9 @@ export const CycleTransferStatsClient: React.FC<
<div className="text-xs text-stone-500 dark:text-stone-400">
Next update: {new Date(nextUpdate).toLocaleString()}
</div>
<section className="flex items-center gap-2">
<span className="text-stone-600 dark:text-stone-400 text-xs">
{new Date(from).toLocaleDateString()} -{" "}
{new Date(to).toLocaleDateString()}
</span>
<div className=" bg-blue-600 text-white px-1 py-0.5 rounded text-[10px]">
{name}
</div>
</section>
<span className="text-xs text-stone-600 dark:text-stone-400 font-semibold">
{formatBytes(transfer)} / {formatBytes(max)}
</span>
</section>
</div>
);