mirror of
https://github.com/Buriburizaem0n/nezha-dash-v1.git
synced 2026-02-05 21:20:08 +00:00
feat: CycleTransferStats display by group
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
import { CycleTransferStats } from "@/types/nezha-api"
|
||||
import { CycleTransferStats, NezhaServer } from "@/types/nezha-api"
|
||||
import React from "react"
|
||||
|
||||
import { CycleTransferStatsClient } from "./CycleTransferStatsClient"
|
||||
|
||||
interface CycleTransferStatsProps {
|
||||
serverList: NezhaServer[]
|
||||
cycleStats: CycleTransferStats
|
||||
className?: string
|
||||
}
|
||||
|
||||
export const CycleTransferStatsCard: React.FC<CycleTransferStatsProps> = ({ cycleStats, className }) => {
|
||||
export const CycleTransferStatsCard: React.FC<CycleTransferStatsProps> = ({ serverList, cycleStats, className }) => {
|
||||
if (serverList.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
const serverIdList = serverList.map((server) => server.id.toString())
|
||||
|
||||
return (
|
||||
<section className="grid grid-cols-1 md:grid-cols-2 gap-2 md:gap-4">
|
||||
{Object.entries(cycleStats).map(([cycleId, cycleData]) => {
|
||||
@@ -20,6 +27,10 @@ export const CycleTransferStatsCard: React.FC<CycleTransferStatsProps> = ({ cycl
|
||||
const transfer = cycleData.transfer?.[serverId] || 0
|
||||
const nextUpdate = cycleData.next_update?.[serverId]
|
||||
|
||||
if (!serverIdList.includes(serverId)) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (!transfer && !nextUpdate) {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user