refactor(errors): migrate decisions to {code,msg}
This commit is contained in:
+4
-4
@@ -1,4 +1,4 @@
|
||||
import { deny } from "@/lib/policy/assert"
|
||||
import { deny } from "@/lib/decision"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
import { useDisputeStore } from "@/store/disputes"
|
||||
|
||||
@@ -13,7 +13,7 @@ export function getDisputeByOrderId(orderId: string) {
|
||||
export function submitDispute(input: { orderId: string; reason: string; evidence: string[] }) {
|
||||
const user = useAuthStore.getState().user
|
||||
if (!user?.id || !user.nickname) {
|
||||
return { decision: deny("AUTH_REQUIRED", "请先登录") }
|
||||
return { decision: deny(401, "请先登录") }
|
||||
}
|
||||
|
||||
return useDisputeStore.getState().submitDispute({
|
||||
@@ -32,7 +32,7 @@ export function submitDisputeResponse(input: {
|
||||
}) {
|
||||
const userId = useAuthStore.getState().user?.id
|
||||
if (!userId) {
|
||||
return deny("AUTH_REQUIRED", "请先登录")
|
||||
return deny(401, "请先登录")
|
||||
}
|
||||
|
||||
return useDisputeStore
|
||||
@@ -43,7 +43,7 @@ export function submitDisputeResponse(input: {
|
||||
export function submitDisputeAppeal(input: { disputeId: string; reason: string }) {
|
||||
const userId = useAuthStore.getState().user?.id
|
||||
if (!userId) {
|
||||
return deny("AUTH_REQUIRED", "请先登录")
|
||||
return deny(401, "请先登录")
|
||||
}
|
||||
|
||||
return useDisputeStore.getState().submitAppeal(input.disputeId, userId, input.reason)
|
||||
|
||||
Reference in New Issue
Block a user