fix: complete disputed order flow and wallet entry

This commit is contained in:
zetaloop
2026-02-21 15:43:21 +08:00
parent e2e0b5a06a
commit 1ff499720f
3 changed files with 64 additions and 30 deletions
+44 -30
View File
@@ -9,7 +9,7 @@ import { statusLabels } from "@/lib/constants"
import { mockChatSessions, mockOrders, mockReviews } from "@/lib/mock" import { mockChatSessions, mockOrders, mockReviews } from "@/lib/mock"
import type { OrderStatus } from "@/lib/types" import type { OrderStatus } from "@/lib/types"
const statusSteps: OrderStatus[] = [ const normalStatusSteps: OrderStatus[] = [
"pending_payment", "pending_payment",
"pending_accept", "pending_accept",
"in_progress", "in_progress",
@@ -18,6 +18,16 @@ const statusSteps: OrderStatus[] = [
"completed", "completed",
] ]
const disputedStatusSteps: OrderStatus[] = [
"pending_payment",
"pending_accept",
"in_progress",
"pending_close",
"disputed",
]
const cancelledStatusSteps: OrderStatus[] = ["pending_payment", "pending_accept", "cancelled"]
export default async function OrderDetailPage({ params }: { params: Promise<{ id: string }> }) { export default async function OrderDetailPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params const { id } = await params
const order = mockOrders.find((o) => o.id === id) const order = mockOrders.find((o) => o.id === id)
@@ -25,6 +35,12 @@ export default async function OrderDetailPage({ params }: { params: Promise<{ id
const reviews = mockReviews.filter((r) => r.orderId === id) const reviews = mockReviews.filter((r) => r.orderId === id)
const chatSession = mockChatSessions.find((s) => s.orderId === id) const chatSession = mockChatSessions.find((s) => s.orderId === id)
const statusSteps =
order.status === "disputed"
? disputedStatusSteps
: order.status === "cancelled"
? cancelledStatusSteps
: normalStatusSteps
const currentStepIndex = statusSteps.indexOf(order.status) const currentStepIndex = statusSteps.indexOf(order.status)
return ( return (
@@ -42,36 +58,34 @@ export default async function OrderDetailPage({ params }: { params: Promise<{ id
<Badge variant="outline">{statusLabels[order.status]}</Badge> <Badge variant="outline">{statusLabels[order.status]}</Badge>
</div> </div>
{order.status !== "disputed" && order.status !== "cancelled" && ( <Card className="mb-6">
<Card className="mb-6"> <CardContent className="pt-6">
<CardContent className="pt-6"> <div className="flex items-center justify-between">
<div className="flex items-center justify-between"> {statusSteps.map((step, i) => {
{statusSteps.map((step, i) => { const isActive = i <= currentStepIndex
const isActive = i <= currentStepIndex const isCurrent = i === currentStepIndex
const isCurrent = i === currentStepIndex return (
return ( <div key={step} className="flex flex-col items-center gap-1 flex-1">
<div key={step} className="flex flex-col items-center gap-1 flex-1"> <div
<div className={`h-8 w-8 rounded-full flex items-center justify-center text-xs font-medium ${
className={`h-8 w-8 rounded-full flex items-center justify-center text-xs font-medium ${ isCurrent
isCurrent ? "bg-primary text-primary-foreground"
? "bg-primary text-primary-foreground" : isActive
: isActive ? "bg-primary/20 text-primary"
? "bg-primary/20 text-primary" : "bg-muted text-muted-foreground"
: "bg-muted text-muted-foreground" }`}
}`} >
> {isActive ? <CheckCircle className="h-4 w-4" /> : i + 1}
{isActive ? <CheckCircle className="h-4 w-4" /> : i + 1}
</div>
<span className="text-[10px] text-muted-foreground text-center">
{statusLabels[step]}
</span>
</div> </div>
) <span className="text-[10px] text-muted-foreground text-center">
})} {statusLabels[step]}
</div> </span>
</CardContent> </div>
</Card> )
)} })}
</div>
</CardContent>
</Card>
<Card className="mb-6"> <Card className="mb-6">
<CardHeader> <CardHeader>
+5
View File
@@ -166,6 +166,11 @@ export default function NewOrderPage() {
<CreditCard className="h-4 w-4" /> <CreditCard className="h-4 w-4" />
<span>: ¥{walletBalance}</span> <span>: ¥{walletBalance}</span>
{walletBalance < totalPrice && <span className="text-destructive"></span>} {walletBalance < totalPrice && <span className="text-destructive"></span>}
{walletBalance < totalPrice && (
<Button variant="outline" size="sm" asChild>
<Link href="/wallet"></Link>
</Button>
)}
</div> </div>
<div className="flex items-center gap-2 text-xs text-muted-foreground"> <div className="flex items-center gap-2 text-xs text-muted-foreground">
<ShieldCheck className="h-3.5 w-3.5" /> <ShieldCheck className="h-3.5 w-3.5" />
+15
View File
@@ -116,6 +116,21 @@ export default function OrderActions({
</Link> </Link>
</Button> </Button>
)} )}
{status === "cancelled" && (
<Button variant="outline" asChild>
<Link href={`/order/new?serviceId=${serviceId}`}>
<RefreshCw className="mr-1 h-4 w-4" />
</Link>
</Button>
)}
{status === "disputed" && (
<Button variant="outline" asChild>
<Link href={`/dispute/${orderId}`}></Link>
</Button>
)}
</div> </div>
) )
} }