From 8ee06cceaae44fdba6b3dcf5ce3444de0dbc32cd Mon Sep 17 00:00:00 2001 From: susie-laptop Date: Tue, 3 Jun 2025 09:56:18 -0400 Subject: [PATCH] [dev]template --- src/components/TemplateList.jsx | 6 +++--- src/lib/constant.js | 10 ++++++++++ src/pages/InboxTemplate.jsx | 33 ++++++++++++++++++------------- src/store/index.js | 2 ++ src/store/slices/creatorsSlice.js | 12 +++++++---- src/store/slices/inboxSlice.js | 6 +++--- src/styles/Brands.scss | 1 - src/styles/DatabaseList.scss | 1 - src/styles/Inbox.scss | 2 +- 9 files changed, 46 insertions(+), 27 deletions(-) diff --git a/src/components/TemplateList.jsx b/src/components/TemplateList.jsx index 04a55af..f8cf381 100644 --- a/src/components/TemplateList.jsx +++ b/src/components/TemplateList.jsx @@ -22,7 +22,7 @@ export default function TemplateList({ activeTab, openModal, setFormData }) { mission: template.type, platform: template.platform, service: template.service, - content: template.content, + content: template.preview, title: template.title, category: template.category, collaboration_type: template.collaboration_type, @@ -49,7 +49,7 @@ export default function TemplateList({ activeTab, openModal, setFormData }) { {template.mission === 'follow_up' && ( 合作追踪 )}{' '} - - {template.name} + - {template.title}
-
{template.content}
+
{template.preview}
))} diff --git a/src/lib/constant.js b/src/lib/constant.js index 5e32e4c..679fa73 100644 --- a/src/lib/constant.js +++ b/src/lib/constant.js @@ -151,3 +151,13 @@ export const TEMPLATE_MISSIONS = [ { value: 'script', name: '脚本邮件' }, { value: 'follow_up', name: '合作追踪' }, ]; + +export const STATUS_OPTIONS = [ + { value: 'brand_review', name: '品牌回顾' }, + { value: 'price_negotiation', name: '价格谈判' }, + { value: 'contract_review', name: '合同确认' }, + { value: 'draft_ready', name: '准备合同' }, + { value: 'draft_approved', name: '合同提交' }, + { value: 'accepted', name: '已接受' }, + { value: 'abandoned', name: '已放弃' }, +]; diff --git a/src/pages/InboxTemplate.jsx b/src/pages/InboxTemplate.jsx index 1c08011..3437955 100644 --- a/src/pages/InboxTemplate.jsx +++ b/src/pages/InboxTemplate.jsx @@ -23,7 +23,11 @@ export default function InboxTemplate() { const dispatch = useDispatch(); useEffect(() => { - dispatch(fetchTemplates(activeTab)); + if (activeTab === 'all') { + dispatch(fetchTemplates()); + } else { + dispatch(fetchTemplates({ mission: activeTab })); + } }, [dispatch, activeTab]); return ( @@ -46,14 +50,14 @@ export default function InboxTemplate() { 全部
setActiveTab('initial')} + className={`tab-switch-item ${activeTab === 'initial_contact' ? 'active' : ''}`} + onClick={() => setActiveTab('initial_contact')} > 初步建联
setActiveTab('bargain')} + className={`tab-switch-item ${activeTab === 'negotiation' ? 'active' : ''}`} + onClick={() => setActiveTab('negotiation')} > 砍价邮件
@@ -64,8 +68,8 @@ export default function InboxTemplate() { 脚本邮件
setActiveTab('cooperation')} + className={`tab-switch-item ${activeTab === 'follow_up' ? 'active' : ''}`} + onClick={() => setActiveTab('follow_up')} > 合作追踪
@@ -104,7 +108,6 @@ function AddTemplateModal({ show, formData, setFormData, handleClose, type = 'ad }; const handleSubmit = () => { - console.log(formData); if (type === 'add') { dispatch(addTemplateThunk(formData)); } else { @@ -146,11 +149,11 @@ function AddTemplateModal({ show, formData, setFormData, handleClose, type = 'ad - { - TEMPLATE_MISSIONS.map((mission) => ( - - )) - } + {TEMPLATE_MISSIONS.map((mission) => ( + + ))} @@ -185,7 +188,9 @@ function AddTemplateModal({ show, formData, setFormData, handleClose, type = 'ad Select service {CAMPAIGN_SERVICES.map((service) => ( - + ))} diff --git a/src/store/index.js b/src/store/index.js index 6302509..ab047ad 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -9,6 +9,7 @@ import authReducer from './slices/authSlice'; import discoveryReducer from './slices/discoverySlice'; import notificationBarReducer from './slices/notificationBarSlice'; import productReducer from './slices/productSlice'; +import chatReducer from './slices/chatSlice'; const authPersistConfig = { key: 'auth', @@ -24,6 +25,7 @@ const rootReducer = combineReducers({ auth: persistReducer(authPersistConfig, authReducer), notificationBar: notificationBarReducer, products: productReducer, + chat: chatReducer, }); const store = configureStore({ diff --git a/src/store/slices/creatorsSlice.js b/src/store/slices/creatorsSlice.js index 9aa6819..7807a6e 100644 --- a/src/store/slices/creatorsSlice.js +++ b/src/store/slices/creatorsSlice.js @@ -513,16 +513,20 @@ const creatorsSlice = createSlice({ state.error = action.error.message; }) .addCase(fetchCreatorMetrics.fulfilled, (state, action) => { - state.selectedCreator.metricsData = action.payload; + console.log(action.payload); + state.selectedCreator.metricsData = action.payload || null; }) .addCase(fetchCreatorFollowers.fulfilled, (state, action) => { - state.selectedCreator.followerData = action.payload; + console.log(action.payload); + state.selectedCreator.followerData = action.payload || null; }) .addCase(fetchCreatorTrends.fulfilled, (state, action) => { - state.selectedCreator.trendsData = action.payload; + console.log(action.payload); + state.selectedCreator.trendsData = action.payload || null; }) .addCase(fetchCreatorVideos.fulfilled, (state, action) => { - state.selectedCreator.videosData = action.payload; + console.log(action.payload); + state.selectedCreator.videosData = action.payload || null; }) .addCase(searchCreators.pending, (state) => { state.status = 'loading'; diff --git a/src/store/slices/inboxSlice.js b/src/store/slices/inboxSlice.js index 9c517e5..2d6fbf4 100644 --- a/src/store/slices/inboxSlice.js +++ b/src/store/slices/inboxSlice.js @@ -191,9 +191,9 @@ export const fetchChatHistory = createAsyncThunk('inbox/fetchChatHistory', async return { chatHistory: mockChatHistory, chatId: id }; }); -export const fetchTemplates = createAsyncThunk('inbox/fetchTemplates', async (_, { rejectWithValue }) => { +export const fetchTemplates = createAsyncThunk('inbox/fetchTemplates', async (query, { rejectWithValue }) => { try { - const response = await api.get('/template/'); + const response = await api.get('/template/', { params: query }); if (response.code === 200) { return response.data.results; } else { @@ -226,7 +226,7 @@ export const addTemplateThunk = createAsyncThunk( async (formData, { rejectWithValue, dispatch }) => { try { const response = await api.post('/template/', formData); - if (response.code === 200) { + if (response.code === 200 || response.code === 201) { return response.data; } else { throw new Error(response.message); diff --git a/src/styles/Brands.scss b/src/styles/Brands.scss index d81c1d7..7d4a785 100644 --- a/src/styles/Brands.scss +++ b/src/styles/Brands.scss @@ -414,7 +414,6 @@ #addProductForm { .modal-body { - width: 400px; display: flex; flex-flow: column nowrap; gap: 1rem; diff --git a/src/styles/DatabaseList.scss b/src/styles/DatabaseList.scss index 5db0533..3b69935 100644 --- a/src/styles/DatabaseList.scss +++ b/src/styles/DatabaseList.scss @@ -12,7 +12,6 @@ position: relative; } .creator-database-table { - height: 100%; position: relative; .creator-cell { diff --git a/src/styles/Inbox.scss b/src/styles/Inbox.scss index 597b088..e0ee046 100644 --- a/src/styles/Inbox.scss +++ b/src/styles/Inbox.scss @@ -366,7 +366,7 @@ gap: 1rem; margin-top: 1rem; overflow-y: auto; - height: calc(100% - 85px); + max-height: calc(100% - 85px); padding-bottom: 1rem; .template-item {