"use client" 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" import { Textarea } from "@/components/ui/textarea" import { addShopAnnouncement, deleteShopAnnouncement, updateShop } from "@/lib/api" 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 { AlertCircle, DollarSign, Edit, ExternalLink, ListOrdered, Star, Users } from "lucide-react" import Link from "next/link" import { useState } from "react" export default function ShopManagementPage() { const { shop, setShop, loading, error, refreshShop } = useMyShop() if (loading) { return (
) } if (error) { return (
) } if (!shop) { return (
) } return ( ) } function ShopManagementContent({ shop, setShop, refreshShop, }: { shop: Shop setShop: (shop: Shop | null) => void refreshShop: () => Promise }) { const [name, setName] = useState(shop.name) const [description, setDescription] = useState(shop.description) const [saving, setSaving] = useState(false) const handleSave = async () => { setSaving(true) try { const nextShop = await updateShop(shop.id, { name, description, commissionType: shop.commissionType, commissionValue: shop.commissionValue, allowMultiShop: shop.allowMultiShop, allowIndependentOrders: shop.allowIndependentOrders, dispatchMode: shop.dispatchMode, }) setShop(nextShop) notifySuccess("店铺信息已保存") } catch (error) { notifyInfo(toApiError(error).msg) } finally { setSaving(false) } } const handleAddAnnouncement = async () => { const next = window.prompt("", "") if (next === null) return const value = next.trim() if (!value) return setSaving(true) try { await addShopAnnouncement(shop.id, value) await refreshShop() notifySuccess("公告已添加") } catch (error) { notifyInfo(toApiError(error).msg) } finally { setSaving(false) } } const handleDeleteAnnouncement = async (index: number) => { setSaving(true) try { await deleteShopAnnouncement(shop.id, index) await refreshShop() notifySuccess("公告已删除") } catch (error) { notifyInfo(toApiError(error).msg) } finally { setSaving(false) } } return (

店铺管理

总订单
{shop.totalOrders}
评分
{shop.rating}
签约打手
{shop.playerCount}
抽成比例
{shop.commissionType === "percentage" ? `${shop.commissionValue}%` : `¥${shop.commissionValue}`}
基本信息
setName(event.target.value)} />