refactor(errors): migrate decisions to {code,msg}

This commit is contained in:
zetaloop
2026-02-28 07:21:51 +08:00
parent 4e2ee5be54
commit cc24a0cbc3
23 changed files with 157 additions and 165 deletions
+8 -10
View File
@@ -8,6 +8,7 @@ import {
payOrder,
requestClose,
} from "@/lib/api/orders"
import type { ApiDecision } from "@/lib/errors"
import { notifyInfo, notifySuccess } from "@/lib/toast"
import type { OrderStatus } from "@/lib/types"
import { useAuthStore } from "@/store/auth"
@@ -59,17 +60,14 @@ export default function OrderActions({
const isConsumer = order?.consumerId === currentUserId
const isPlayer = order?.playerId === currentUserId
const handleDecision = useCallback(
(okMessage: string, result: { decision: { ok: boolean; message?: string } }) => {
if (result.decision.ok) {
showFeedback(okMessage)
return
}
const handleDecision = useCallback((okMessage: string, result: { decision: ApiDecision }) => {
if (result.decision.ok) {
showFeedback(okMessage)
return
}
notifyInfo(result.decision.message ?? "当前操作不允许")
},
[],
)
notifyInfo(result.decision.error.msg)
}, [])
return (
<div className="flex gap-2 flex-wrap">