Skip to content

Conversation

@Fengfeng2010
Copy link
Contributor

@Fengfeng2010 Fengfeng2010 commented Jan 24, 2026

例行检查

  • 我已阅读并理解 贡献者公约
  • 我已阅读并同意 贡献者许可协议 (CLA),确认我的贡献将根据项目的 Apache2.0 许可证进行许可
  • 我知晓如果此 PR 并不做出实质性更改,或可被认为是为了PR被合并而提交PR的,则可能不会被合并

关联信息

fix: #181

@Fengfeng2010
Copy link
Contributor Author

@small-lovely-cat w~

@Fengfeng2010
Copy link
Contributor Author

@chenyme

@small-lovely-cat
Copy link
Contributor

small-lovely-cat commented Jan 24, 2026

export function ViewDisputeHistoryDialog({ order }: { order: Order }) {
  // ...
  const disputeConfig = useMemo(() => {
    switch (order.status) {
      case 'refused':
        return {
          tooltip: '争议已拒绝,点击查看',
          timelineText: '服务方驳回争议',
          timelineColor: 'destructive',
          showTimestamp: true,
          showContent: false,
          content: null
        }
      case 'refund':
        return {
          tooltip: '争议已退款',
          timelineText: '服务方已退款',
          timelineColor: 'primary',
          showTimestamp: true,
          showContent: true,
          content: '退款已完成'
        }
      case 'disputing':
        return {
          tooltip: '争议处理中,点击查看',
          timelineText: '争议进行中',
          timelineColor: 'primary',
          showTimestamp: false,
          showContent: false,
          content: null
        }
      default:
        return {
          tooltip: '未知状态',
          timelineText: '未知状态',
          timelineColor: 'primary',
          showTimestamp: false,
          showContent: false,
          content: null
        }
    }
  }, [order.status])

  return (
    <>
      <Tooltip>
        <TooltipTrigger asChild>
          {/* ... */}
        </TooltipTrigger>
        <TooltipContent side="top">
          <p>{disputeConfig.tooltip}</p>
        </TooltipContent>
      </Tooltip>
      
      <Dialog open={open} onOpenChange={handleOpenChange}>
        {/* ... */}
        <div className="relative">
          <div className={`absolute -left-[21px] top-1 h-2.5 w-2.5 rounded-full 
            ${disputeConfig.timelineColor === 'destructive' ? 'bg-destructive' : 'bg-primary'} 
            ring-4 ring-background`} 
          />
          <div className="space-y-1">
            <div className="flex items-center justify-between">
              <span className={`text-sm font-medium ${disputeConfig.timelineColor === 'destructive' ? 'text-destructive' : ''}`}>
                {disputeConfig.timelineText}
              </span>
              {disputeConfig.showTimestamp && (
                <span className="text-xs text-muted-foreground">
                  {formatDateTime(disputeHistory.updated_at)}
                </span>
              )}
            </div>
            
            {order.status === 'refused' && (
              <div className="text-sm text-muted-foreground bg-destructive/5 border border-destructive/10 p-3 rounded-md">
                {parseDisputeReason(disputeHistory.reason).merchantReason || "未提供拒绝理由"}
              </div>
            )}
            
            {disputeConfig.showContent && disputeConfig.content && (
              <div className="text-sm text-muted-foreground bg-muted/50 p-3 rounded-md">
                {disputeConfig.content}
              </div>
            )}
          </div>
        </div>
      </Dialog>
    </>
  )
}

猫猫看了一下,好像把语言合并一下这样更好欸 owo
相当于统一维护一个状态映射,比单独维护三个更清晰,也可以少判断几次当前的状态,性能可能好一些 w?

@Fengfeng2010
Copy link
Contributor Author

看不懂qwq
晕晕的w

@small-lovely-cat
Copy link
Contributor

small-lovely-cat commented Jan 24, 2026

5368f49

改成像这样就行了喵 owo @Fengfeng2010

@Fengfeng2010 Fengfeng2010 marked this pull request as draft January 24, 2026 13:36
@Fengfeng2010 Fengfeng2010 marked this pull request as ready for review January 24, 2026 13:50
@Fengfeng2010
Copy link
Contributor Author

62ed2e2 w?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: dispute dialog issue

2 participants