refactor(order): add transition evaluator and timer constants
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 { DISPUTE_TO_RESOLVED_MS } from "@/lib/config/demo-timers"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
@@ -342,7 +343,9 @@ export default function DisputePage({ params }: { params: Promise<{ id: string }
|
||||
<div className="container mx-auto py-8 px-4 max-w-lg text-center space-y-4">
|
||||
<AlertTriangle className="h-12 w-12 mx-auto text-yellow-500" />
|
||||
<h2 className="text-xl font-bold">争议已提交,请等待平台处理</h2>
|
||||
<p className="text-sm text-muted-foreground">平台将在 3 个工作日内审核你的争议申请。</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
平台将在约 {Math.floor(DISPUTE_TO_RESOLVED_MS / 1000)} 秒内给出模拟处理结果。
|
||||
</p>
|
||||
<Link href={`/order/${id}`} className="text-sm text-primary hover:underline">
|
||||
返回订单详情
|
||||
</Link>
|
||||
@@ -434,7 +437,7 @@ export default function DisputePage({ params }: { params: Promise<{ id: string }
|
||||
<div className="rounded-md bg-muted/50 p-3 text-xs text-muted-foreground space-y-1">
|
||||
<p>· 提交争议后,订单资金将继续托管</p>
|
||||
<p>· 聊天记录将作为证据保留</p>
|
||||
<p>· 平台将在 3 个工作日内审核</p>
|
||||
<p>· 平台将在约 {Math.floor(DISPUTE_TO_RESOLVED_MS / 1000)} 秒内完成模拟审核</p>
|
||||
<p>· 对仲裁结果不满可申诉一次</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { use, useEffect, useMemo, useState } from "react"
|
||||
import OrderActions from "@/components/order-actions"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { ORDER_ACCEPT_TIMEOUT_MS, ORDER_CLOSE_TIMEOUT_MS } from "@/lib/config/demo-timers"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { statusLabels } from "@/lib/constants"
|
||||
import type { OrderStatus } from "@/lib/types"
|
||||
@@ -85,11 +86,13 @@ export default function OrderDetailPage({ params }: { params: Promise<{ id: stri
|
||||
order.status === "pending_accept"
|
||||
? new Date(order.createdAt).getTime()
|
||||
: new Date(order.closedAt ?? order.createdAt).getTime()
|
||||
const remainSeconds = Math.max(0, 30 - Math.floor((nowTs - base) / 1000))
|
||||
const timeoutMs =
|
||||
order.status === "pending_accept" ? ORDER_ACCEPT_TIMEOUT_MS : ORDER_CLOSE_TIMEOUT_MS
|
||||
const remainSeconds = Math.max(0, Math.ceil((timeoutMs - (nowTs - base)) / 1000))
|
||||
|
||||
return order.status === "pending_accept"
|
||||
? `若 30 秒内无人接单,订单将自动取消(剩余 ${remainSeconds} 秒)`
|
||||
: `若 30 秒内未确认,订单将自动进入待评价(剩余 ${remainSeconds} 秒)`
|
||||
? `若 ${Math.floor(ORDER_ACCEPT_TIMEOUT_MS / 1000)} 秒内无人接单,订单将自动取消(剩余 ${remainSeconds} 秒)`
|
||||
: `若 ${Math.floor(ORDER_CLOSE_TIMEOUT_MS / 1000)} 秒内未确认,订单将自动进入待评价(剩余 ${remainSeconds} 秒)`
|
||||
})()
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user