CreatorCenter_OOIN/src/components/TemplateList.jsx

87 lines
3.6 KiB
React
Raw Normal View History

2025-05-21 22:49:54 +08:00
import { Copy, Edit, FileText, LayoutTemplate } from 'lucide-react';
import { Button } from 'react-bootstrap';
import { useSelector } from 'react-redux';
2025-05-29 07:23:13 +08:00
import Spinning from './SpinningComponent';
2025-05-21 22:49:54 +08:00
2025-05-22 06:13:14 +08:00
export default function TemplateList({ activeTab, openModal, setFormData }) {
2025-05-21 22:49:54 +08:00
const { templates, templatesStatus } = useSelector((state) => state.inbox);
// 如果正在加载,显示加载中
if (templatesStatus === 'loading') {
return <Spinning />;
}
if (templates.length === 0) {
return (
<div className='template-list-empty'>
<span className='template-list-empty-text'>No templates found</span>
</div>
);
}
2025-05-22 06:13:14 +08:00
const handleEdit = (template) => {
setFormData({
id: template.id,
mission: template.type,
platform: template.platform,
service: template.service,
2025-06-03 21:56:18 +08:00
content: template.preview,
2025-05-30 08:17:01 +08:00
title: template.title,
category: template.category,
collaboration_type: template.collaboration_type,
is_public: template.is_public,
2025-05-22 06:13:14 +08:00
});
openModal();
}
2025-05-21 22:49:54 +08:00
return (
<div className='template-list'>
{templates.map((template) => (
<div className='template-item' key={template.id}>
<div className='template-item-name'>
<span className='template-item-name-text'>
2025-05-30 08:17:37 +08:00
{template.mission === 'initial_contact' && (
2025-05-21 22:49:54 +08:00
<span className='template-item-name-text-initial'>初步建联</span>
)}
2025-05-30 08:17:37 +08:00
{template.mission === 'negotiation' && (
2025-05-21 22:49:54 +08:00
<span className='template-item-name-text-bargain'>砍价邮件</span>
)}
2025-05-30 08:17:37 +08:00
{template.mission === 'script' && (
2025-05-21 22:49:54 +08:00
<span className='template-item-name-text-script'>脚本邮件</span>
)}
2025-05-30 08:17:37 +08:00
{template.mission === 'follow_up' && (
2025-05-21 22:49:54 +08:00
<span className='template-item-name-text-cooperation'>合作追踪</span>
)}{' '}
2025-06-03 21:56:18 +08:00
- {template.title}
2025-05-21 22:49:54 +08:00
</span>
<div className='template-item-name-actions'>
2025-05-22 06:13:14 +08:00
<Button variant='outline-primary' className='border-0' size='sm' onClick={() => handleEdit(template)}>
2025-05-21 22:49:54 +08:00
<Edit size={16} />
Edit
</Button>
</div>
</div>
<div className='template-item-item template-platform'>
<div className='label'>
<LayoutTemplate size={20} />
Platform
</div>
<div className='value'>{template.platform}</div>
</div>
<div className='template-item-item template-service'>
<div className='label'>
<Copy size={20} />
Service
</div>
<div className='value'>{template.service}</div>
</div>
<div className='template-item-item template-message'>
<div className='label'>
<FileText size={20} />
Message
</div>
2025-06-03 21:56:18 +08:00
<div className='value'>{template.preview}</div>
2025-05-21 22:49:54 +08:00
</div>
</div>
))}
</div>
);
}