fix(review): enforce pending-review submission and remove auto reply

This commit is contained in:
zetaloop
2026-02-22 15:18:38 +08:00
parent 385dac2d49
commit ca95165e1b
2 changed files with 48 additions and 31 deletions
+21 -1
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 { notifyInfo, notifySuccess } from "@/lib/toast"
import { useAuthStore } from "@/store/auth"
import { useOrderStore } from "@/store/orders"
import { useReviewStore } from "@/store/reviews"
@@ -37,6 +38,18 @@ export default function ReviewPage({ params }: { params: Promise<{ id: string }>
const hasSubmitted = Boolean(userId && reviews.some((review) => review.fromUserId === userId))
const isRevealed = reviews.length >= 2 && reviews.every((review) => !review.sealed)
if (order.status !== "pending_review") {
return (
<div className="container mx-auto py-8 px-4 max-w-lg text-center space-y-4">
<h2 className="text-xl font-bold"></h2>
<p className="text-sm text-muted-foreground"></p>
<Link href={`/order/${id}`} className="text-sm text-primary hover:underline">
</Link>
</div>
)
}
if (hasSubmitted && !isRevealed) {
return (
<div className="container mx-auto py-8 px-4 max-w-lg text-center space-y-4">
@@ -126,12 +139,19 @@ export default function ReviewPage({ params }: { params: Promise<{ id: string }>
disabled={rating === 0 || !userId}
onClick={() => {
if (!userId) return
submitReview({
const decision = submitReview({
orderId: id,
fromUserId: userId,
rating,
content,
})
if (decision.ok) {
notifySuccess("评价已提交")
return
}
notifyInfo(decision.message ?? "评价提交失败")
}}
>