From d3ce3593b85b4d53f72f2212ed340893d8bcfc5e Mon Sep 17 00:00:00 2001
From: AlliotTech <24980252+AlliotTech@users.noreply.github.com>
Date: Fri, 6 Feb 2026 15:58:07 +0800
Subject: [PATCH] feat: implement RequestState and RequestSkeleton components;
refactor device and settings pages to use new components
---
app/(dashboard)/page.tsx | 63 ++++++----------
app/device/device-detail-client.tsx | 79 +++++++++------------
app/settings/page.tsx | 21 +++---
components/dashboard/device-card.tsx | 9 ++-
components/dashboard/device-list-mobile.tsx | 53 ++++++--------
components/dashboard/device-list.tsx | 60 +++++-----------
components/device/device-summary.tsx | 5 +-
components/ui/confirm-action-dialog.tsx | 52 ++++++++++++++
components/ui/request-skeleton.tsx | 19 +++++
components/ui/request-state.tsx | 27 +++++++
lib/format.ts | 6 ++
next-env.d.ts | 2 +-
12 files changed, 217 insertions(+), 179 deletions(-)
create mode 100644 components/ui/confirm-action-dialog.tsx
create mode 100644 components/ui/request-skeleton.tsx
create mode 100644 components/ui/request-state.tsx
diff --git a/app/(dashboard)/page.tsx b/app/(dashboard)/page.tsx
index cd59088..43c4665 100644
--- a/app/(dashboard)/page.tsx
+++ b/app/(dashboard)/page.tsx
@@ -6,15 +6,16 @@ import { RefreshCcw } from "lucide-react";
import { SummaryCards } from "@/components/dashboard/summary-cards";
import { DeviceList } from "@/components/dashboard/device-list";
import { DeviceListMobile } from "@/components/dashboard/device-list-mobile";
-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
-import { Skeleton } from "@/components/ui/skeleton";
import { useI18n } from "@/lib/i18n";
import { useSettings, useSummary, useSummaryTemp } from "@/lib/hooks";
import { toast } from "sonner";
import { DurationKey } from "@/lib/constants";
import { TempChartSection } from "@/components/dashboard/temp-chart-section";
+import { RequestState } from "@/components/ui/request-state";
+import { RequestSkeleton } from "@/components/ui/request-skeleton";
+import { Skeleton } from "@/components/ui/skeleton";
export default function DashboardPage() {
const { t } = useI18n();
@@ -49,30 +50,21 @@ export default function DashboardPage() {
if (summary.error) {
return (
- {String(summary.error)}
{t("dashboard.subtitle")}
-{t("dashboard.empty.body")}
-{String(details.error)}
- -{String(settings.error)}
- -{message}
+ {actionLabel && onAction ? ( + + ) : null} +