feat(ui): refine dashboard management pages

This commit is contained in:
zetaloop
2026-04-25 21:45:32 +08:00
parent 1ee512940e
commit 14f6f5509a
4 changed files with 146 additions and 78 deletions
+45 -28
View File
@@ -3,6 +3,7 @@
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { EmptyState } from "@/components/ui/empty-state"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Separator } from "@/components/ui/separator"
@@ -12,7 +13,7 @@ import { toApiError } from "@/lib/errors"
import { useMyShop } from "@/lib/hooks/use-my-shop"
import { notifyInfo, notifySuccess } from "@/lib/toast"
import type { Shop } from "@/lib/types"
import { DollarSign, Edit, ExternalLink, ListOrdered, Star, Users } from "lucide-react"
import { AlertCircle, DollarSign, Edit, ExternalLink, ListOrdered, Star, Users } from "lucide-react"
import Link from "next/link"
import { useState } from "react"
@@ -20,15 +21,27 @@ export default function ShopManagementPage() {
const { shop, setShop, loading, error, refreshShop } = useMyShop()
if (loading) {
return <div className="text-sm text-muted-foreground">...</div>
return (
<div className="container mx-auto max-w-6xl px-4 py-8">
<EmptyState title="店铺信息加载中" icon={ListOrdered} />
</div>
)
}
if (error) {
return <div className="text-sm text-muted-foreground">{error}</div>
return (
<div className="container mx-auto max-w-6xl px-4 py-8">
<EmptyState title="店铺信息加载失败" description={error} icon={AlertCircle} />
</div>
)
}
if (!shop) {
return <div className="text-sm text-muted-foreground"></div>
return (
<div className="container mx-auto max-w-6xl px-4 py-8">
<EmptyState title="当前账号没有可管理的店铺" icon={ListOrdered} />
</div>
)
}
return (
@@ -114,7 +127,7 @@ function ShopManagementContent({
</div>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
<Card className="hover:shadow-card-hover">
<Card className="border-border/80 shadow-sm">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<ListOrdered className="h-4 w-4 text-muted-foreground" />
@@ -123,7 +136,7 @@ function ShopManagementContent({
<div className="text-2xl font-bold">{shop.totalOrders}</div>
</CardContent>
</Card>
<Card className="hover:shadow-card-hover">
<Card className="border-border/80 shadow-sm">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<Star className="h-4 w-4 text-muted-foreground" />
@@ -132,7 +145,7 @@ function ShopManagementContent({
<div className="text-2xl font-bold">{shop.rating}</div>
</CardContent>
</Card>
<Card className="hover:shadow-card-hover">
<Card className="border-border/80 shadow-sm">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<Users className="h-4 w-4 text-muted-foreground" />
@@ -141,7 +154,7 @@ function ShopManagementContent({
<div className="text-2xl font-bold">{shop.playerCount}</div>
</CardContent>
</Card>
<Card className="hover:shadow-card-hover">
<Card className="border-border/80 shadow-sm">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<DollarSign className="h-4 w-4 text-muted-foreground" />
@@ -156,7 +169,7 @@ function ShopManagementContent({
</Card>
</div>
<Card className="hover:shadow-card-hover">
<Card className="border-border/80 shadow-sm">
<CardHeader>
<CardTitle className="text-base"></CardTitle>
</CardHeader>
@@ -186,29 +199,33 @@ function ShopManagementContent({
</CardContent>
</Card>
<Card className="hover:shadow-card-hover">
<Card className="border-border/80 shadow-sm">
<CardHeader>
<CardTitle className="text-base"></CardTitle>
</CardHeader>
<CardContent className="space-y-3">
{shop.announcements.map((announcement, index) => (
<div
key={announcement}
className="flex items-center justify-between rounded-md border p-3"
>
<span className="text-sm">{announcement}</span>
<Button
variant="ghost"
size="sm"
onClick={() => {
void handleDeleteAnnouncement(index)
}}
disabled={saving}
{shop.announcements.length > 0 ? (
shop.announcements.map((announcement, index) => (
<div
key={announcement}
className="flex items-center justify-between rounded-md border border-border/60 p-3"
>
</Button>
</div>
))}
<span className="text-sm">{announcement}</span>
<Button
variant="ghost"
size="sm"
onClick={() => {
void handleDeleteAnnouncement(index)
}}
disabled={saving}
>
</Button>
</div>
))
) : (
<EmptyState title="暂无公告" className="min-h-[180px] border-dashed" />
)}
<Separator />
<Button
variant="outline"
@@ -223,7 +240,7 @@ function ShopManagementContent({
</CardContent>
</Card>
<Card className="hover:shadow-card-hover">
<Card className="border-border/80 shadow-sm">
<CardHeader>
<CardTitle className="text-base"></CardTitle>
</CardHeader>