fix(shop): use backend shop in navigation
This commit is contained in:
@@ -12,11 +12,10 @@ import {
|
||||
isDisputedOrder,
|
||||
isPendingDispatch,
|
||||
} from "@/lib/domain/order-filters"
|
||||
import { resolveOwnerShop } from "@/lib/domain/resolve-current-shop"
|
||||
import { useMyShop } from "@/lib/hooks/use-my-shop"
|
||||
import type { OrderStatus, UserRole } from "@/lib/types"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
import { useShopStore } from "@/store/shops"
|
||||
import { Clock, MessageSquare, RefreshCw } from "lucide-react"
|
||||
import Link from "next/link"
|
||||
import { useEffect, useState } from "react"
|
||||
@@ -65,8 +64,19 @@ function getOrderRole(role: UserRole): "consumer" | "player" | "owner" | undefin
|
||||
|
||||
export default function OrderListPage() {
|
||||
const { currentRole, user } = useAuthStore()
|
||||
const shops = useShopStore((state) => state.shops)
|
||||
const ownerShop = resolveOwnerShop(user?.id, shops)
|
||||
const {
|
||||
shop: ownerShop,
|
||||
loading: shopLoading,
|
||||
error: shopError,
|
||||
} = useMyShop(currentRole === "owner")
|
||||
|
||||
if (currentRole === "owner" && shopLoading) {
|
||||
return <div className="text-sm text-muted-foreground">加载中...</div>
|
||||
}
|
||||
|
||||
if (currentRole === "owner" && shopError) {
|
||||
return <div className="text-sm text-muted-foreground">{shopError}</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<OrderListContent
|
||||
|
||||
@@ -15,12 +15,12 @@ import {
|
||||
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
|
||||
import { getCurrentUserForLogin, logout as logoutRequest, switchCurrentRole } from "@/lib/api"
|
||||
import { toApiError } from "@/lib/errors"
|
||||
import { useMyShop } from "@/lib/hooks/use-my-shop"
|
||||
import { notifyInfo } from "@/lib/toast"
|
||||
import type { UserRole } from "@/lib/types"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
import { useNotificationStore } from "@/store/notifications"
|
||||
import { useShopStore } from "@/store/shops"
|
||||
import {
|
||||
Bell,
|
||||
Gamepad2,
|
||||
@@ -57,10 +57,8 @@ export function Header() {
|
||||
logout: clearAuth,
|
||||
user,
|
||||
} = useAuthStore()
|
||||
const ownerShop = useShopStore((state) =>
|
||||
user ? state.shops.find((shop) => shop.owner.id === user.id) : undefined,
|
||||
)
|
||||
const canOpenDashboard = currentRole === "player" || currentRole === "owner"
|
||||
const { shop: ownerShop } = useMyShop(isAuthenticated && currentRole === "owner")
|
||||
|
||||
const navLinks =
|
||||
currentRole === "consumer"
|
||||
|
||||
Reference in New Issue
Block a user