From 1619ed22a0743e239b6bfbb2be882b4af62937ed Mon Sep 17 00:00:00 2001 From: Timothy Yin Date: Wed, 11 Mar 2026 11:22:24 +0800 Subject: [PATCH] feat(web): enhance charge point status display with fault indication and link to details --- apps/web/app/dashboard/page.tsx | 101 +++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 22 deletions(-) diff --git a/apps/web/app/dashboard/page.tsx b/apps/web/app/dashboard/page.tsx index 03371ae..ea4baac 100644 --- a/apps/web/app/dashboard/page.tsx +++ b/apps/web/app/dashboard/page.tsx @@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query"; import { Button, Card, Spinner } from "@heroui/react"; +import Link from "next/link"; import { Thunderbolt, PlugConnection, @@ -10,6 +11,7 @@ import { TagDollar, Person, ArrowRotateRight, + TriangleExclamation, } from "@gravity-ui/icons"; import { useSession } from "@/lib/auth-client"; import { api, type Stats, type UserStats, type Transaction, type ChargePoint } from "@/lib/api"; @@ -87,7 +89,7 @@ function StatCard({ function Panel({ title, children }: { title: string; children: React.ReactNode }) { return ( -
+

{title}

@@ -156,25 +158,61 @@ function ChargePointStatus({ cps }: { cps: ChargePoint[] }) { const online = cpOnline(cp); const chargingCount = cp.connectors.filter((c) => c.status === "Charging").length; const availableCount = cp.connectors.filter((c) => c.status === "Available").length; + const faultedCount = cp.connectors.filter((c) => c.status === "Faulted").length; return ( -
  • - -
    -

    - {cp.chargePointIdentifier} -

    -

    - {cp.chargePointModel ?? cp.chargePointVendor ?? "未知型号"} -

    -
    -
    - {chargingCount > 0 && ( -

    {chargingCount} 充电中

    - )} -

    {online ? `${availableCount} 可用` : "离线"}

    -
    +
  • + + +
    +

    + {cp.chargePointIdentifier} +

    +

    + {cp.chargePointModel ?? cp.chargePointVendor ?? "未知型号"} +

    +
    +
    + {online ? ( +
    + {/* Charge point status */} + {cp.chargePointStatus === "Faulted" && ( +
    +
    + + 整桩故障 +
    +
    + )} + {/* Status summary */} +
    + {faultedCount > 0 && ( +
    + + {faultedCount} +
    + )} + {chargingCount > 0 && ( +
    + + {chargingCount} +
    + )} +
    + + {availableCount} +
    +
    +
    + ) : ( +
    离线
    + )} +
    +
  • ); })} @@ -188,7 +226,12 @@ export default function DashboardPage() { const { data: sessionData, isPending } = useSession(); const isAdmin = sessionData?.user?.role === "admin"; - const { data, isPending: queryPending, isFetching: refreshing, refetch } = useQuery({ + const { + data, + isPending: queryPending, + isFetching: refreshing, + refetch, + } = useQuery({ queryKey: ["dashboard", isAdmin], queryFn: async () => { const [statsRes, txRes, cpsData] = await Promise.all([ @@ -231,7 +274,14 @@ export default function DashboardPage() {

    概览

    实时运营状态

    -
    @@ -339,7 +389,14 @@ export default function DashboardPage() { {sessionData?.user?.name ?? sessionData?.user?.email} 的账户概览

    -