"use client"
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 {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import { 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, Save } from "lucide-react"
import { useState } from "react"
export default function ShopRulesPage() {
const { shop, setShop, loading, error } = useMyShop()
if (loading) {
return (
)
}
if (error) {
return (
)
}
if (!shop) {
return (
)
}
return
}
function ShopRulesForm({ shop, setShop }: { shop: Shop; setShop: (shop: Shop | null) => void }) {
const [commissionType, setCommissionType] = useState(shop.commissionType)
const [commissionValue, setCommissionValue] = useState(shop.commissionValue)
const [allowMultiShop, setAllowMultiShop] = useState(shop.allowMultiShop)
const [allowIndependentOrders, setAllowIndependentOrders] = useState(shop.allowIndependentOrders)
const [dispatchMode, setDispatchMode] = useState(shop.dispatchMode)
const [saving, setSaving] = useState(false)
const handleSave = async () => {
setSaving(true)
try {
const nextShop = await updateShop(shop.id, {
name: shop.name,
description: shop.description,
commissionType,
commissionValue,
allowMultiShop,
allowIndependentOrders,
dispatchMode,
})
setShop(nextShop)
notifySuccess("规则已保存")
} catch (error) {
notifyInfo(toApiError(error).msg)
} finally {
setSaving(false)
}
}
return (
规则设置
员工权限
派单设置
手动指派需要店主确认分配;自动匹配将根据打手状态自动分单
抽成设置
)
}