refactor(api): add adapter layer for order/chat/review/dispute writes
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { submitDispute, submitDisputeAppeal, submitDisputeResponse } from "@/lib/api/disputes"
|
||||
import { DISPUTE_TO_RESOLVED_MS } from "@/lib/config/demo-timers"
|
||||
import { notifyInfo } from "@/lib/toast"
|
||||
import { Label } from "@/components/ui/label"
|
||||
@@ -38,11 +39,7 @@ export default function DisputePage({ params }: { params: Promise<{ id: string }
|
||||
const searchParams = useSearchParams()
|
||||
const order = useOrderStore((state) => state.orders.find((item) => item.id === id))
|
||||
const userId = useAuthStore((state) => state.user?.id)
|
||||
const userName = useAuthStore((state) => state.user?.nickname)
|
||||
const existingDispute = useDisputeStore((state) => state.getDisputeByOrderId(id))
|
||||
const submitDispute = useDisputeStore((state) => state.submitDispute)
|
||||
const submitResponse = useDisputeStore((state) => state.submitResponse)
|
||||
const submitAppeal = useDisputeStore((state) => state.submitAppeal)
|
||||
|
||||
const [reason, setReason] = useState("")
|
||||
const [files, setFiles] = useState<string[]>([])
|
||||
@@ -108,11 +105,9 @@ export default function DisputePage({ params }: { params: Promise<{ id: string }
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!userId || !userName || !reason.trim()) return
|
||||
if (!userId || !reason.trim()) return
|
||||
const result = submitDispute({
|
||||
orderId: id,
|
||||
initiatorId: userId,
|
||||
initiatorName: userName,
|
||||
reason,
|
||||
evidence: files,
|
||||
})
|
||||
@@ -287,12 +282,11 @@ export default function DisputePage({ params }: { params: Promise<{ id: string }
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (!userId) return
|
||||
const decision = submitResponse(
|
||||
existingDispute.id,
|
||||
userId,
|
||||
responseReason,
|
||||
responseFiles,
|
||||
)
|
||||
const decision = submitDisputeResponse({
|
||||
disputeId: existingDispute.id,
|
||||
reason: responseReason,
|
||||
evidence: responseFiles,
|
||||
})
|
||||
if (!decision.ok) {
|
||||
notifyInfo(decision.message ?? "提交回应失败")
|
||||
}
|
||||
@@ -337,7 +331,10 @@ export default function DisputePage({ params }: { params: Promise<{ id: string }
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
if (!userId) return
|
||||
const decision = submitAppeal(existingDispute.id, userId, appealReason)
|
||||
const decision = submitDisputeAppeal({
|
||||
disputeId: existingDispute.id,
|
||||
reason: appealReason,
|
||||
})
|
||||
if (!decision.ok) {
|
||||
notifyInfo(decision.message ?? "提交申诉失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user