fix(review): enforce pending-review submission and remove auto reply
This commit is contained in:
@@ -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 ?? "评价提交失败")
|
||||
}}
|
||||
>
|
||||
提交评价
|
||||
|
||||
Reference in New Issue
Block a user