refactor(api): add adapter layer for order/chat/review/dispute writes

This commit is contained in:
zetaloop
2026-02-23 11:04:16 +08:00
parent 1dfcd3927d
commit 8e62b15403
10 changed files with 258 additions and 98 deletions
+6 -3
View File
@@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { submitReview } from "@/lib/api/reviews"
import { notifyInfo, notifySuccess } from "@/lib/toast"
import { useAuthStore } from "@/store/auth"
import { useOrderStore } from "@/store/orders"
@@ -16,7 +17,6 @@ export default function ReviewPage({ params }: { params: Promise<{ id: string }>
const { id } = use(params)
const order = useOrderStore((state) => state.orders.find((item) => item.id === id))
const userId = useAuthStore((state) => state.user?.id)
const submitReview = useReviewStore((state) => state.submitReview)
const allReviews = useReviewStore((state) => state.reviews)
// The selector returns the raw store array and useMemo derives the subset.
// This keeps useSyncExternalStore snapshots stable across render checks.
@@ -138,10 +138,13 @@ export default function ReviewPage({ params }: { params: Promise<{ id: string }>
className="w-full"
disabled={rating === 0 || !userId}
onClick={() => {
if (!userId) return
if (!userId) {
notifyInfo("请先登录")
return
}
const decision = submitReview({
orderId: id,
fromUserId: userId,
rating,
content,
})