refactor(order): add transition evaluator and timer constants

This commit is contained in:
zetaloop
2026-02-23 11:03:31 +08:00
parent 03fa447864
commit 6517018a9c
6 changed files with 188 additions and 8 deletions
+4 -1
View File
@@ -1,4 +1,5 @@
import { create } from "zustand"
import { ORDER_ACCEPT_TIMEOUT_MS, ORDER_CLOSE_TIMEOUT_MS } from "@/lib/config/demo-timers"
import { generateId } from "@/lib/id"
import { mockOrders } from "@/lib/mock"
import type { Order, OrderStatus, PlayerService } from "@/lib/types"
@@ -39,6 +40,8 @@ function scheduleOrderTimeout(orderId: string, status: OrderStatus) {
return
}
const timeoutMs = status === "pending_accept" ? ORDER_ACCEPT_TIMEOUT_MS : ORDER_CLOSE_TIMEOUT_MS
const timer = setTimeout(() => {
const state = useOrderStore.getState()
const order = state.orders.find((item) => item.id === orderId)
@@ -56,7 +59,7 @@ function scheduleOrderTimeout(orderId: string, status: OrderStatus) {
}
orderTimeouts.delete(orderId)
}, 30000)
}, timeoutMs)
orderTimeouts.set(orderId, timer)
}