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
+33
View File
@@ -0,0 +1,33 @@
import type { OrderStatus } from "@/lib/types"
const ACTIVE_STATUSES: ReadonlySet<OrderStatus> = new Set([
"pending_payment",
"pending_accept",
"in_progress",
"pending_close",
"pending_review",
])
const COMPLETED_STATUSES: ReadonlySet<OrderStatus> = new Set(["completed"])
const DISPUTED_STATUSES: ReadonlySet<OrderStatus> = new Set(["disputed"])
const PENDING_DISPATCH_STATUSES: ReadonlySet<OrderStatus> = new Set(["pending_accept"])
export function isActiveOrder(status: OrderStatus) {
return ACTIVE_STATUSES.has(status)
}
export function isCompletedOrder(status: OrderStatus, options?: { includeCancelled?: boolean }) {
if (options?.includeCancelled && status === "cancelled") {
return true
}
return COMPLETED_STATUSES.has(status)
}
export function isDisputedOrder(status: OrderStatus) {
return DISPUTED_STATUSES.has(status)
}
export function isPendingDispatch(status: OrderStatus) {
return PENDING_DISPATCH_STATUSES.has(status)
}
+6
View File
@@ -0,0 +1,6 @@
import type { Shop } from "@/lib/types"
export function resolveOwnerShop(userId: string | undefined, shops: Shop[]): Shop | null {
if (!userId) return null
return shops.find((shop) => shop.owner.id === userId) ?? null
}