feat(ui): refine dashboard management pages
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge"
|
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
|
import { EmptyState } from "@/components/ui/empty-state"
|
||||||
import { Progress } from "@/components/ui/progress"
|
import { Progress } from "@/components/ui/progress"
|
||||||
|
import { StatusBadge, type StatusBadgeProps } from "@/components/ui/status-badge"
|
||||||
import { listOrders, listPlayers, listServices, listShops } from "@/lib/api"
|
import { listOrders, listPlayers, listServices, listShops } from "@/lib/api"
|
||||||
import { statusLabels } from "@/lib/constants"
|
import { statusLabels } from "@/lib/constants"
|
||||||
import type { Player, PlayerService, Shop } from "@/lib/types"
|
import type { Player, PlayerService, Shop } from "@/lib/types"
|
||||||
@@ -12,6 +13,17 @@ import { CheckCircle, Clock, DollarSign, ListOrdered, Star, TrendingUp, Users }
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
|
|
||||||
|
const orderStatusVariants: Record<string, StatusBadgeProps["status"]> = {
|
||||||
|
pending_payment: "warning",
|
||||||
|
pending_accept: "info",
|
||||||
|
in_progress: "success",
|
||||||
|
pending_close: "info",
|
||||||
|
pending_review: "info",
|
||||||
|
disputed: "destructive",
|
||||||
|
completed: "success",
|
||||||
|
cancelled: "neutral",
|
||||||
|
}
|
||||||
|
|
||||||
function getOrderRole(role: "consumer" | "player" | "owner" | "admin") {
|
function getOrderRole(role: "consumer" | "player" | "owner" | "admin") {
|
||||||
if (role === "consumer" || role === "player" || role === "owner") {
|
if (role === "consumer" || role === "player" || role === "owner") {
|
||||||
return role
|
return role
|
||||||
@@ -87,7 +99,7 @@ export default function DashboardPage() {
|
|||||||
<h1 className="text-2xl font-bold">概览</h1>
|
<h1 className="text-2xl font-bold">概览</h1>
|
||||||
|
|
||||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
<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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">总订单</CardTitle>
|
<CardTitle className="text-sm font-medium">总订单</CardTitle>
|
||||||
<ListOrdered className="h-4 w-4 text-muted-foreground" />
|
<ListOrdered className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -96,7 +108,7 @@ export default function DashboardPage() {
|
|||||||
<div className="text-2xl font-bold">{totalOrders}</div>
|
<div className="text-2xl font-bold">{totalOrders}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">评分</CardTitle>
|
<CardTitle className="text-sm font-medium">评分</CardTitle>
|
||||||
<Star className="h-4 w-4 text-muted-foreground" />
|
<Star className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -105,7 +117,7 @@ export default function DashboardPage() {
|
|||||||
<div className="text-2xl font-bold">{rating}</div>
|
<div className="text-2xl font-bold">{rating}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">{isOwner ? "签约打手" : "完成率"}</CardTitle>
|
<CardTitle className="text-sm font-medium">{isOwner ? "签约打手" : "完成率"}</CardTitle>
|
||||||
{isOwner ? (
|
{isOwner ? (
|
||||||
@@ -125,7 +137,7 @@ export default function DashboardPage() {
|
|||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">{isOwner ? "本月收入" : "服务数"}</CardTitle>
|
<CardTitle className="text-sm font-medium">{isOwner ? "本月收入" : "服务数"}</CardTitle>
|
||||||
{isOwner ? (
|
{isOwner ? (
|
||||||
@@ -140,7 +152,7 @@ export default function DashboardPage() {
|
|||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader className="flex flex-row items-center justify-between">
|
<CardHeader className="flex flex-row items-center justify-between">
|
||||||
<CardTitle className="text-base">最近订单</CardTitle>
|
<CardTitle className="text-base">最近订单</CardTitle>
|
||||||
<Button variant="ghost" size="sm" asChild>
|
<Button variant="ghost" size="sm" asChild>
|
||||||
@@ -148,29 +160,33 @@ export default function DashboardPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-3">
|
{recentOrders.length > 0 ? (
|
||||||
{recentOrders.map((order) => (
|
<div className="space-y-3">
|
||||||
<Link key={order.id} href={`/order/${order.id}`}>
|
{recentOrders.map((order) => (
|
||||||
<div className="flex items-center justify-between rounded-md border p-3 hover:bg-muted/50 transition-colors">
|
<Link key={order.id} href={`/order/${order.id}`}>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="flex items-center justify-between rounded-md border border-border/60 p-3 transition-colors hover:bg-muted/50">
|
||||||
<p className="text-sm font-medium truncate">{order.service.title}</p>
|
<div className="min-w-0 flex-1">
|
||||||
<p className="text-xs text-muted-foreground">{order.service.title}</p>
|
<p className="truncate text-sm font-medium">{order.service.title}</p>
|
||||||
|
<p className="text-xs text-muted-foreground">{order.service.title}</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex shrink-0 items-center gap-3">
|
||||||
|
<span className="text-sm font-medium tabular-nums">¥{order.totalPrice}</span>
|
||||||
|
<StatusBadge status={orderStatusVariants[order.status] ?? "neutral"}>
|
||||||
|
{statusLabels[order.status]}
|
||||||
|
</StatusBadge>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3 shrink-0">
|
</Link>
|
||||||
<span className="text-sm font-medium">¥{order.totalPrice}</span>
|
))}
|
||||||
<Badge variant="outline" className="text-xs">
|
</div>
|
||||||
{statusLabels[order.status]}
|
) : (
|
||||||
</Badge>
|
<EmptyState title="暂无最近订单" icon={ListOrdered} className="min-h-[180px]" />
|
||||||
</div>
|
)}
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{!isOwner && (
|
{!isOwner && (
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">快捷操作</CardTitle>
|
<CardTitle className="text-base">快捷操作</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
|
import { EmptyState } from "@/components/ui/empty-state"
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
@@ -17,7 +18,7 @@ import { useMyShop } from "@/lib/hooks/use-my-shop"
|
|||||||
import { notifyInfo, notifySuccess } from "@/lib/toast"
|
import { notifyInfo, notifySuccess } from "@/lib/toast"
|
||||||
import type { Player, PlayerService } from "@/lib/types"
|
import type { Player, PlayerService } from "@/lib/types"
|
||||||
import { useAuthStore } from "@/store/auth"
|
import { useAuthStore } from "@/store/auth"
|
||||||
import { Edit, Plus, Trash2 } from "lucide-react"
|
import { AlertCircle, Edit, Plus, Trash2 } from "lucide-react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ export default function ServicesPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">已发布的服务</CardTitle>
|
<CardTitle className="text-base">已发布的服务</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
@@ -128,20 +129,30 @@ export default function ServicesPage() {
|
|||||||
<TableBody>
|
<TableBody>
|
||||||
{loading || (currentRole === "owner" && shopLoading) ? (
|
{loading || (currentRole === "owner" && shopLoading) ? (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={6} className="text-center text-sm text-muted-foreground">
|
<TableCell colSpan={6} className="py-6">
|
||||||
加载中...
|
<EmptyState title="服务加载中" className="min-h-[180px]" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : currentRole === "owner" && shopError ? (
|
) : currentRole === "owner" && shopError ? (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={6} className="text-center text-sm text-muted-foreground">
|
<TableCell colSpan={6} className="py-6">
|
||||||
{shopError}
|
<EmptyState
|
||||||
|
title="店铺信息加载失败"
|
||||||
|
description={shopError}
|
||||||
|
icon={AlertCircle}
|
||||||
|
className="min-h-[180px]"
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : scopedServices.length === 0 ? (
|
) : scopedServices.length === 0 ? (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={6} className="text-center text-sm text-muted-foreground">
|
<TableCell colSpan={6} className="py-6">
|
||||||
暂无服务
|
<EmptyState
|
||||||
|
title="暂无服务"
|
||||||
|
description="发布服务后会出现在这里。"
|
||||||
|
icon={Plus}
|
||||||
|
className="min-h-[180px] border-dashed"
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
|
import { EmptyState } from "@/components/ui/empty-state"
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
@@ -16,7 +17,7 @@ import { listWalletTransactions } from "@/lib/api/transactions"
|
|||||||
import { toApiError } from "@/lib/errors"
|
import { toApiError } from "@/lib/errors"
|
||||||
import { useMyShop } from "@/lib/hooks/use-my-shop"
|
import { useMyShop } from "@/lib/hooks/use-my-shop"
|
||||||
import type { WalletTransaction } from "@/lib/types"
|
import type { WalletTransaction } from "@/lib/types"
|
||||||
import { ArrowDownLeft, ArrowUpRight, CreditCard, DollarSign } from "lucide-react"
|
import { AlertCircle, ArrowDownLeft, ArrowUpRight, CreditCard, DollarSign } from "lucide-react"
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
|
|
||||||
const emptyStats: ShopIncomeStats = {
|
const emptyStats: ShopIncomeStats = {
|
||||||
@@ -67,15 +68,27 @@ export default function ShopIncomePage() {
|
|||||||
}, [shop])
|
}, [shop])
|
||||||
|
|
||||||
if (loading) {
|
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={CreditCard} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
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) {
|
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={CreditCard} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const relatedTransactions = transactions.filter(
|
const relatedTransactions = transactions.filter(
|
||||||
@@ -87,7 +100,7 @@ export default function ShopIncomePage() {
|
|||||||
<h1 className="text-2xl font-bold">收入统计</h1>
|
<h1 className="text-2xl font-bold">收入统计</h1>
|
||||||
|
|
||||||
<div className="grid gap-4 sm:grid-cols-3">
|
<div className="grid gap-4 sm:grid-cols-3">
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">本月收入</CardTitle>
|
<CardTitle className="text-sm font-medium">本月收入</CardTitle>
|
||||||
<DollarSign className="h-4 w-4 text-muted-foreground" />
|
<DollarSign className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -96,7 +109,7 @@ export default function ShopIncomePage() {
|
|||||||
<div className="text-2xl font-bold">¥{stats.monthlyIncome}</div>
|
<div className="text-2xl font-bold">¥{stats.monthlyIncome}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">待结算</CardTitle>
|
<CardTitle className="text-sm font-medium">待结算</CardTitle>
|
||||||
<CreditCard className="h-4 w-4 text-muted-foreground" />
|
<CreditCard className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -105,7 +118,7 @@ export default function ShopIncomePage() {
|
|||||||
<div className="text-2xl font-bold">¥{stats.pendingSettlement}</div>
|
<div className="text-2xl font-bold">¥{stats.pendingSettlement}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">累计提现</CardTitle>
|
<CardTitle className="text-sm font-medium">累计提现</CardTitle>
|
||||||
<ArrowUpRight className="h-4 w-4 text-muted-foreground" />
|
<ArrowUpRight className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -116,7 +129,7 @@ export default function ShopIncomePage() {
|
|||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>交易明细</CardTitle>
|
<CardTitle>交易明细</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
@@ -133,14 +146,19 @@ export default function ShopIncomePage() {
|
|||||||
<TableBody>
|
<TableBody>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={4} className="text-center py-8 text-muted-foreground text-sm">
|
<TableCell colSpan={4} className="py-6">
|
||||||
加载中...
|
<EmptyState title="交易加载中" icon={CreditCard} className="min-h-[180px]" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : loadError ? (
|
) : loadError ? (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={4} className="text-center py-8 text-destructive text-sm">
|
<TableCell colSpan={4} className="py-6">
|
||||||
{loadError}
|
<EmptyState
|
||||||
|
title="交易加载失败"
|
||||||
|
description={loadError}
|
||||||
|
icon={AlertCircle}
|
||||||
|
className="min-h-[180px]"
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : relatedTransactions.length > 0 ? (
|
) : relatedTransactions.length > 0 ? (
|
||||||
@@ -149,11 +167,11 @@ export default function ShopIncomePage() {
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{Number(transaction.amount) > 0 ? (
|
{Number(transaction.amount) > 0 ? (
|
||||||
<ArrowDownLeft className="h-4 w-4 text-green-500" />
|
<ArrowDownLeft className="h-4 w-4 text-success" />
|
||||||
) : (
|
) : (
|
||||||
<ArrowUpRight className="h-4 w-4 text-red-500" />
|
<ArrowUpRight className="h-4 w-4 text-destructive" />
|
||||||
)}
|
)}
|
||||||
<Badge variant={Number(transaction.amount) > 0 ? "default" : "secondary"}>
|
<Badge variant={Number(transaction.amount) > 0 ? "success" : "destructive"}>
|
||||||
{transaction.type === "topup"
|
{transaction.type === "topup"
|
||||||
? "充值"
|
? "充值"
|
||||||
: transaction.type === "payment"
|
: transaction.type === "payment"
|
||||||
@@ -168,7 +186,9 @@ export default function ShopIncomePage() {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{transaction.description}</TableCell>
|
<TableCell>{transaction.description}</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
className={Number(transaction.amount) > 0 ? "text-green-600" : "text-red-600"}
|
className={
|
||||||
|
Number(transaction.amount) > 0 ? "text-success" : "text-destructive"
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{Number(transaction.amount) > 0 ? "+" : ""}
|
{Number(transaction.amount) > 0 ? "+" : ""}
|
||||||
{transaction.amount}
|
{transaction.amount}
|
||||||
@@ -178,8 +198,12 @@ export default function ShopIncomePage() {
|
|||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell colSpan={4} className="text-center py-8 text-muted-foreground text-sm">
|
<TableCell colSpan={4} className="py-6">
|
||||||
暂无交易记录
|
<EmptyState
|
||||||
|
title="暂无交易记录"
|
||||||
|
icon={CreditCard}
|
||||||
|
className="min-h-[180px] border-dashed"
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
|
import { EmptyState } from "@/components/ui/empty-state"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/components/ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
import { Separator } from "@/components/ui/separator"
|
import { Separator } from "@/components/ui/separator"
|
||||||
@@ -12,7 +13,7 @@ import { toApiError } from "@/lib/errors"
|
|||||||
import { useMyShop } from "@/lib/hooks/use-my-shop"
|
import { useMyShop } from "@/lib/hooks/use-my-shop"
|
||||||
import { notifyInfo, notifySuccess } from "@/lib/toast"
|
import { notifyInfo, notifySuccess } from "@/lib/toast"
|
||||||
import type { Shop } from "@/lib/types"
|
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 Link from "next/link"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
|
|
||||||
@@ -20,15 +21,27 @@ export default function ShopManagementPage() {
|
|||||||
const { shop, setShop, loading, error, refreshShop } = useMyShop()
|
const { shop, setShop, loading, error, refreshShop } = useMyShop()
|
||||||
|
|
||||||
if (loading) {
|
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) {
|
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) {
|
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 (
|
return (
|
||||||
@@ -114,7 +127,7 @@ function ShopManagementContent({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
<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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">总订单</CardTitle>
|
<CardTitle className="text-sm font-medium">总订单</CardTitle>
|
||||||
<ListOrdered className="h-4 w-4 text-muted-foreground" />
|
<ListOrdered className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -123,7 +136,7 @@ function ShopManagementContent({
|
|||||||
<div className="text-2xl font-bold">{shop.totalOrders}</div>
|
<div className="text-2xl font-bold">{shop.totalOrders}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">评分</CardTitle>
|
<CardTitle className="text-sm font-medium">评分</CardTitle>
|
||||||
<Star className="h-4 w-4 text-muted-foreground" />
|
<Star className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -132,7 +145,7 @@ function ShopManagementContent({
|
|||||||
<div className="text-2xl font-bold">{shop.rating}</div>
|
<div className="text-2xl font-bold">{shop.rating}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">签约打手</CardTitle>
|
<CardTitle className="text-sm font-medium">签约打手</CardTitle>
|
||||||
<Users className="h-4 w-4 text-muted-foreground" />
|
<Users className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -141,7 +154,7 @@ function ShopManagementContent({
|
|||||||
<div className="text-2xl font-bold">{shop.playerCount}</div>
|
<div className="text-2xl font-bold">{shop.playerCount}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-sm font-medium">抽成比例</CardTitle>
|
<CardTitle className="text-sm font-medium">抽成比例</CardTitle>
|
||||||
<DollarSign className="h-4 w-4 text-muted-foreground" />
|
<DollarSign className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -156,7 +169,7 @@ function ShopManagementContent({
|
|||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">基本信息</CardTitle>
|
<CardTitle className="text-base">基本信息</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
@@ -186,29 +199,33 @@ function ShopManagementContent({
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">公告管理</CardTitle>
|
<CardTitle className="text-base">公告管理</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-3">
|
<CardContent className="space-y-3">
|
||||||
{shop.announcements.map((announcement, index) => (
|
{shop.announcements.length > 0 ? (
|
||||||
<div
|
shop.announcements.map((announcement, index) => (
|
||||||
key={announcement}
|
<div
|
||||||
className="flex items-center justify-between rounded-md border p-3"
|
key={announcement}
|
||||||
>
|
className="flex items-center justify-between rounded-md border border-border/60 p-3"
|
||||||
<span className="text-sm">{announcement}</span>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => {
|
|
||||||
void handleDeleteAnnouncement(index)
|
|
||||||
}}
|
|
||||||
disabled={saving}
|
|
||||||
>
|
>
|
||||||
删除
|
<span className="text-sm">{announcement}</span>
|
||||||
</Button>
|
<Button
|
||||||
</div>
|
variant="ghost"
|
||||||
))}
|
size="sm"
|
||||||
|
onClick={() => {
|
||||||
|
void handleDeleteAnnouncement(index)
|
||||||
|
}}
|
||||||
|
disabled={saving}
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<EmptyState title="暂无公告" className="min-h-[180px] border-dashed" />
|
||||||
|
)}
|
||||||
<Separator />
|
<Separator />
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@@ -223,7 +240,7 @@ function ShopManagementContent({
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="hover:shadow-card-hover">
|
<Card className="border-border/80 shadow-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-base">运营设置</CardTitle>
|
<CardTitle className="text-base">运营设置</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
Reference in New Issue
Block a user