refactor(order): add transition evaluator and timer constants
This commit is contained in:
+4
-1
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user