Files
smart-crop-ui/crop-x-new/src/app/(app)/central-config/message/send/components/MessagePreviewDialog.tsx
peng 6cddddb601 fix: 修复系统模块TypeScript类型错误和组件功能问题
- 修复消息组件JSX.Element类型错误,改为React.ReactNode
- 完善审核历史页面类型定义和API接口调用
- 优化验证码组件,移除备用验证码逻辑避免无限循环
- 简化系统设置页面,仅保留基本设置和外观设置
- 修复用户管理页面编辑模态框数据加载和CRUD操作
- 移除废弃的作物推荐组件文件

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-12 17:28:11 +08:00

122 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
import { Card } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { format } from 'date-fns';
import { zhCN } from 'date-fns/locale';
import { MessageSendRecord } from '@/types/message';
interface MessagePreviewDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
record: MessageSendRecord | null;
getTypeIcon: (type: string) => React.ReactNode;
getTypeLabel: (type: string) => string;
getTypeBadge: (type: string) => string;
getStatusBadge: (status: string) => React.ReactNode;
}
export function MessagePreviewDialog({
open,
onOpenChange,
record,
getTypeIcon,
getTypeLabel,
getTypeBadge,
getStatusBadge
}: MessagePreviewDialogProps) {
if (!record) return null;
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-2xl">
<DialogHeader>
<DialogTitle></DialogTitle>
<DialogDescription className="sr-only">
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
<div className="grid grid-cols-2 gap-4">
<div>
<Label></Label>
<div className="field-value-inline">{record.templateName}</div>
</div>
<div>
<Label></Label>
<div className="mt-2">
<Badge className={getTypeBadge(record.type)}>
<span className="flex items-center gap-1">
{getTypeIcon(record.type)}
{getTypeLabel(record.type)}
</span>
</Badge>
</div>
</div>
<div>
<Label></Label>
<div className="field-value-inline">
{record.sendType === 'immediate' ? '实时发送' : '定时发送'}
</div>
</div>
<div>
<Label></Label>
<div className="mt-2">
{getStatusBadge(record.status)}
</div>
</div>
{record.scheduledTime && (
<div>
<Label></Label>
<div className="field-value-inline">
{format(new Date(record.scheduledTime), 'yyyy-MM-dd HH:mm', { locale: zhCN })}
</div>
</div>
)}
<div>
<Label></Label>
<div className="field-value-inline">
{format(new Date(record.createdAt), 'yyyy-MM-dd HH:mm', { locale: zhCN })}
</div>
</div>
</div>
{record.subject && (
<div>
<Label></Label>
<div className="field-value-inline">{record.subject}</div>
</div>
)}
<div>
<Label> {record.recipientCount} </Label>
<Card className="p-3 bg-gray-50 mt-2">
<div className="flex flex-wrap gap-2">
{record.recipients.map((recipient, index) => (
<Badge key={index} variant="outline">
{recipient}
</Badge>
))}
</div>
</Card>
</div>
<div>
<Label></Label>
<Card className="p-4 bg-blue-50 border-blue-200 mt-2">
<pre className="text-sm whitespace-pre-wrap">
{record.content}
</pre>
</Card>
</div>
</div>
<DialogFooter>
<Button onClick={() => onOpenChange(false)}>
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}