fix(dashboard): scope owner and service views by resolved shop

This commit is contained in:
zetaloop
2026-02-22 17:14:52 +08:00
parent 1f2dc1434b
commit 1dfcd3927d
11 changed files with 269 additions and 70 deletions
+19 -1
View File
@@ -14,13 +14,31 @@ import {
SelectValue,
} from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import { resolveOwnerShop } from "@/lib/domain/resolve-current-shop"
import type { Shop } from "@/lib/types"
import { useAuthStore } from "@/store/auth"
import { useShopStore } from "@/store/shops"
export default function ShopRulesPage() {
const shop = useShopStore((state) => state.shops[0])
const userId = useAuthStore((state) => state.user?.id)
const shops = useShopStore((state) => state.shops)
const shop = resolveOwnerShop(userId, shops)
const updateShop = useShopStore((state) => state.updateShop)
if (!shop) {
return <div className="text-sm text-muted-foreground"></div>
}
return <ShopRulesForm key={shop.id} shop={shop} updateShop={updateShop} />
}
function ShopRulesForm({
shop,
updateShop,
}: {
shop: Shop
updateShop: (shopId: string, patch: Partial<Omit<Shop, "id" | "owner">>) => void
}) {
const [allowMultiShop, setAllowMultiShop] = useState(shop.allowMultiShop)
const [allowIndependentOrders, setAllowIndependentOrders] = useState(shop.allowIndependentOrders)
const [dispatchMode, setDispatchMode] = useState<Shop["dispatchMode"]>(shop.dispatchMode)