refactor(errors): migrate decisions to {code,msg}
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user