Compare commits

..

2 Commits

Author SHA1 Message Date
4653afdefe Update InboxList.jsx 2025-06-04 20:49:10 -04:00
6fd9458d07 [dev]complete edit templates 2025-06-04 20:46:58 -04:00
11 changed files with 46 additions and 23 deletions

View File

@ -4,6 +4,7 @@ import { fetchBrands } from '../store/slices/brandsSlice';
import { Card } from 'react-bootstrap';
import { Folders, Hash, Link, Users } from 'lucide-react';
import SpinningComponent from './SpinningComponent';
import { getBrandSourceName } from '../lib/utils';
export default function BrandsList({ openBrandDetail }) {
const { brands, status, error } = useSelector((state) => state.brands);
@ -37,7 +38,7 @@ export default function BrandsList({ openBrandDetail }) {
<Folders size={16} />
Category
</span>
<span className='card-text-content'>{brand.category}</span>
<span className='card-text-content'>{brand.category || '--'}</span>
</Card.Text>
<Card.Text className=''>
<span className='card-text-title'>
@ -58,7 +59,7 @@ export default function BrandsList({ openBrandDetail }) {
<Link size={16} />
Source
</span>
<span className='card-text-content'>{brand.source}</span>
<span className='card-text-content'>{getBrandSourceName(brand.source)}</span>
</Card.Text>
</Card.Body>
</div>

View File

@ -70,7 +70,6 @@ export default function DiscoveryList() {
function SeesionResultModal({ session, show, onHide }) {
if (!show) return null;
const { creators } = session || {};
console.log(creators);
return (
<Modal show={show} onHide={onHide} size={creators.length > 0 ? 'xl' : ''}>
<Modal.Header closeButton>
@ -134,7 +133,7 @@ function SeesionResultModal({ session, show, onHide }) {
</td>
<td className='text-center'>
<span className={`category-pill ${getCategoryClassName(creator.category)}`}>
{creator.category}
{creator.category || '--'}
</span>
</td>
<td className='text-center'>

View File

@ -68,7 +68,7 @@ export default function InboxList() {
<div className='list-content'>
{status === 'loading' && <div>Loading...</div>}
{status === 'failed' && <div>Error: {error}</div>}
{status === 'succeeded' && inboxList.length > 0 &&
{status === 'succeeded' && (inboxList.length > 0 ?
inboxList.map((item) => (
<div
key={item.id}
@ -91,7 +91,7 @@ export default function InboxList() {
)}
</div>
</div>
))}
)) : <div className='list-item-empty'>No Chats Found</div>)}
</div>
</div>
);

View File

@ -97,7 +97,7 @@ export default function ProductsList({ products, onShowProductDetail, type = 'de
<tbody>
{products?.length === 0 ? (
<tr>
<td colSpan='10' className='text-center py-4'>
<td colSpan='11' className='text-center py-4'>
No products found for this brand.
</td>
</tr>

View File

@ -1,8 +0,0 @@
export default function SessionResult() {
return (
<div>
<h1>Session Result</h1>
</div>
);
}

View File

@ -1,9 +1,11 @@
import { Copy, Edit, FileText, LayoutTemplate } from 'lucide-react';
import { Button } from 'react-bootstrap';
import { useSelector } from 'react-redux';
import { useSelector, useDispatch } from 'react-redux';
import Spinning from './SpinningComponent';
import { getTemplateDetail } from '../store/slices/inboxSlice';
export default function TemplateList({ activeTab, openModal, setFormData }) {
const dispatch = useDispatch();
const { templates, templatesStatus } = useSelector((state) => state.inbox);
//
if (templatesStatus === 'loading') {
@ -16,13 +18,14 @@ export default function TemplateList({ activeTab, openModal, setFormData }) {
</div>
);
}
const handleEdit = (template) => {
const handleEdit = async (template) => {
await dispatch(getTemplateDetail(template.id)).unwrap();
setFormData({
id: template.id,
mission: template.type,
platform: template.platform,
service: template.service,
content: template.preview,
content: template?.content || template.preview,
title: template.title,
category: template.category,
collaboration_type: template.collaboration_type,

View File

@ -145,7 +145,6 @@ export const CREATOR_CATEGORIES = [
];
export const TEMPLATE_MISSIONS = [
{ value: 'all', name: '全部' },
{ value: 'initial_contact', name: '初步建联' },
{ value: 'negotiation', name: '砍价邮件' },
{ value: 'script', name: '脚本邮件' },

View File

@ -1,3 +1,5 @@
import { BRAND_SOURCES } from "./constant";
/**
* 格式化日期
* @param {Date} date - 要格式化的日期对象
@ -51,3 +53,11 @@ export const getCategoryClassName = (category) => {
return categoryMap[category] || '';
};
export const getBrandSourceName = (source) => {
return BRAND_SOURCES.find(item => item.value === source)?.name || source;
};
export const getTemplateMissionName = (mission) => {
return TEMPLATE_MISSIONS.find(item => item.value === mission)?.name || mission;
};

View File

@ -120,6 +120,9 @@ function AddBrandModal({ show, onHide }) {
</Form.Group>
<Form.Group className='mb-3' controlId='formBasicCampaignId'>
<Form.Label>Campaign ID</Form.Label>
<Form.Text className='text-muted'>
这个活动ID没必要在新增品牌的时候添加吧
</Form.Text>
<Form.Control
type='text'
required

View File

@ -238,6 +238,19 @@ export const addTemplateThunk = createAsyncThunk(
}
);
export const getTemplateDetail = createAsyncThunk('inbox/getTemplateDetail', async (id, { rejectWithValue }) => {
try {
const response = await api.get(`/template/${id}/`);
if (response.code === 200) {
return response.data;
} else {
throw new Error(response.message);
}
} catch (error) {
return rejectWithValue(error.response.data.message);
}
});
const initialState = {
inboxList: [],
inboxStatus: 'idle', // 'idle' | 'loading' | 'succeeded' | 'failed'
@ -321,7 +334,13 @@ const inboxSlice = createSlice({
.addCase(addTemplateThunk.rejected, (state, action) => {
state.templatesStatus = 'failed';
state.error = action.payload;
});
})
.addCase(getTemplateDetail.fulfilled, (state, action) => {
const template = state.templates.find(item => item.id === action.payload.id);
if (template) {
Object.assign(template, action.payload);
}
})
},
});

View File

@ -365,9 +365,6 @@
grid-template-columns: repeat(2, 1fr);
gap: 1rem;
margin-top: 1rem;
overflow-y: auto;
max-height: calc(100% - 85px);
padding-bottom: 1rem;
.template-item {
background-color: #fff;