feat: add refresh button to various dashboard pages for improved data fetching

This commit is contained in:
2026-03-11 00:29:04 +08:00
parent 4d0c429d5f
commit a84393590e
5 changed files with 72 additions and 30 deletions

View File

@@ -3,7 +3,7 @@
import { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { Button, Chip, Modal, Pagination, Spinner, Table } from "@heroui/react";
import { TrashBin } from "@gravity-ui/icons";
import { TrashBin, ArrowRotateRight } from "@gravity-ui/icons";
import { api } from "@/lib/api";
import { useSession } from "@/lib/auth-client";
@@ -30,6 +30,7 @@ export default function TransactionsPage() {
const {
data,
isPending: loading,
isFetching: refreshing,
refetch,
} = useQuery({
queryKey: ["transactions", page, status],
@@ -76,7 +77,11 @@ export default function TransactionsPage() {
<h1 className="text-xl font-semibold text-foreground"></h1>
<p className="mt-0.5 text-sm text-muted"> {data?.total ?? "—"} </p>
</div>
<div className="flex gap-1.5 rounded-xl bg-surface-secondary p-1">
<div className="flex items-center gap-2">
<Button isIconOnly size="sm" variant="ghost" isDisabled={refreshing} onPress={() => refetch()} aria-label="刷新">
<ArrowRotateRight className={`size-4 ${refreshing ? "animate-spin" : ""}`} />
</Button>
<div className="flex gap-1.5 rounded-xl bg-surface-secondary p-1">
{(["all", "active", "completed"] as const).map((s) => (
<button
key={s}
@@ -89,8 +94,7 @@ export default function TransactionsPage() {
>
{s === "all" ? "全部" : s === "active" ? "进行中" : "已完成"}
</button>
))}
</div>
))} </div> </div>
</div>
<Table>