refactor(store): adapt Zustand stores to backend-aligned types
- orders: remove name fields from creation, keep dispatchMode logic - chat: remove readonly/senderName/senderAvatar references - reviews: remove fromUserAvatar/toUserId, simplify participant check - disputes: remove initiatorId/initiatorName from creation - posts: remove authorRole/quotedPostId, keep linkedOrderId as number - comments: remove postId from creation - wallet: use string amounts
This commit is contained in:
+7
-10
@@ -28,8 +28,6 @@ export interface DisputeRecord extends Dispute {
|
||||
|
||||
interface SubmitDisputeInput {
|
||||
orderId: string
|
||||
initiatorId: string
|
||||
initiatorName: string
|
||||
reason: string
|
||||
evidence: string[]
|
||||
}
|
||||
@@ -180,7 +178,7 @@ export const useDisputeStore = create<DisputeState>((set, get) => {
|
||||
return { decision: deny(400, "请填写争议原因") }
|
||||
}
|
||||
|
||||
const actor = resolveParticipantActor(input.orderId, input.initiatorId)
|
||||
const actor = resolveParticipantActor(input.orderId, useAuthStore.getState().user?.id ?? "")
|
||||
if (!actor) {
|
||||
return { decision: deny(403, "仅订单参与方可发起争议") }
|
||||
}
|
||||
@@ -194,8 +192,6 @@ export const useDisputeStore = create<DisputeState>((set, get) => {
|
||||
const dispute: DisputeRecord = {
|
||||
id: generateId("disp"),
|
||||
orderId: input.orderId,
|
||||
initiatorId: input.initiatorId,
|
||||
initiatorName: input.initiatorName,
|
||||
reason: input.reason.trim(),
|
||||
evidence: input.evidence,
|
||||
status: "open",
|
||||
@@ -205,7 +201,7 @@ export const useDisputeStore = create<DisputeState>((set, get) => {
|
||||
{
|
||||
id: generateId("timeline"),
|
||||
type: "created",
|
||||
content: `${input.initiatorName} 提交争议`,
|
||||
content: "争议已提交",
|
||||
createdAt,
|
||||
},
|
||||
],
|
||||
@@ -221,15 +217,16 @@ export const useDisputeStore = create<DisputeState>((set, get) => {
|
||||
return deny(404, "争议不存在")
|
||||
}
|
||||
|
||||
const order = useOrderStore.getState().orders.find((item) => item.id === dispute.orderId)
|
||||
if (!order) {
|
||||
return deny(404, "关联订单不存在")
|
||||
}
|
||||
|
||||
const actor = resolveParticipantActor(dispute.orderId, actorId)
|
||||
if (!actor) {
|
||||
return deny(403, "仅订单参与方可提交回应")
|
||||
}
|
||||
|
||||
if (actorId === dispute.initiatorId) {
|
||||
return deny(403, "争议发起方不可提交回应")
|
||||
}
|
||||
|
||||
if (dispute.respondentReason) {
|
||||
return deny(400, "回应已提交")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user