From 2ef64c9192a388cb34ce510afd5db92526ce40cd Mon Sep 17 00:00:00 2001 From: yiekheng Date: Sun, 10 May 2026 00:35:01 +0800 Subject: [PATCH] feat(web): show Re-pair/Delete on accounts list cards Surface state-aware quick actions directly on each card so the user doesn't have to drill into the detail page just to delete or re-pair an account. Re-pair shows when status != connected; Delete (with destructive confirm dialog) is always available. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/src/app/accounts/page.tsx | 134 ++++++++++++++++++++--------- 1 file changed, 95 insertions(+), 39 deletions(-) diff --git a/apps/web/src/app/accounts/page.tsx b/apps/web/src/app/accounts/page.tsx index cfd50da..d7e0405 100644 --- a/apps/web/src/app/accounts/page.tsx +++ b/apps/web/src/app/accounts/page.tsx @@ -1,16 +1,25 @@ import Link from "next/link"; -import { PlusIcon, SmartphoneIcon, CalendarIcon } from "lucide-react"; +import { PlusIcon, SmartphoneIcon, CalendarIcon, PowerIcon, Trash2Icon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle, - CardDescription, } from "@/components/ui/card"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; import { AccountStatusBadge } from "@/components/account-status-badge"; import { getSeededOperator } from "@/lib/operator"; import { listAccounts } from "@/lib/queries"; +import { pairAccountAction, deleteAccountAction } from "@/actions/accounts"; export default async function AccountsPage() { const op = await getSeededOperator(); @@ -25,7 +34,7 @@ export default async function AccountsPage() { {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} - Pair New Account + Add Account @@ -34,45 +43,92 @@ export default async function AccountsPage() { {accounts.length > 0 ? (
{accounts.map((account) => ( - - - -
- {account.label} - + +
+ + {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} + + {account.label} + + + +
+
+ + {account.phoneNumber ? ( +
+ + {account.phoneNumber}
- - - {account.phoneNumber ? ( -
- - {account.phoneNumber} -
- ) : ( -

No phone number

+ ) : ( +

Not paired yet

+ )} + {account.lastConnectedAt ? ( +
+ + + Last connected{" "} + {account.lastConnectedAt.toLocaleDateString("en-MY", { + timeZone: "Asia/Kuala_Lumpur", + year: "numeric", + month: "short", + day: "numeric", + })} + +
+ ) : null} + {/* Quick actions */} +
+ {account.status !== "connected" && ( +
+ + +
)} - {account.lastConnectedAt ? ( -
- - - Last connected{" "} - {account.lastConnectedAt.toLocaleDateString("en-MY", { - timeZone: "Asia/Kuala_Lumpur", - year: "numeric", - month: "short", - day: "numeric", - })} - -
- ) : null} - - - + + + + + + + + Delete this account? + + {account.label} and all its reminders, groups, + and history will be permanently removed. This cannot be undone. + + + +
+ + +
+
+
+
+
+
+ ))}
) : ( @@ -89,7 +145,7 @@ export default async function AccountsPage() { {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} - Pair New Account + Add Account