From b53fe1b6b047a156756cbce4f8347cca668b7eb2 Mon Sep 17 00:00:00 2001 From: William Tso Date: Tue, 11 Mar 2025 15:20:51 +0800 Subject: [PATCH] post comments fix --- web/src/components/Analytics.tsx | 42 +- web/src/components/CommentList.tsx | 898 ++++++++++++++++++++++------- web/src/components/PostList.tsx | 1 + web/src/types.ts | 4 +- 4 files changed, 719 insertions(+), 226 deletions(-) diff --git a/web/src/components/Analytics.tsx b/web/src/components/Analytics.tsx index be4cfe5..2e1301c 100644 --- a/web/src/components/Analytics.tsx +++ b/web/src/components/Analytics.tsx @@ -595,26 +595,21 @@ const Analytics: React.FC = () => { // 项目选择器组件 const ProjectSelector = () => ( -
- -
- -
- -
+
+ +
+
); @@ -624,11 +619,7 @@ const Analytics: React.FC = () => {

Analytics Dashboard

- {/* 添加项目选择器 */} - - - {/* Add the Influencer Tracking Form at the top */} - + {/* 删除这里的项目选择器 */} {loading ? (
@@ -653,6 +644,7 @@ const Analytics: React.FC = () => {

數據分析

+
setSearchQuery(e.target.value)} /> @@ -271,9 +745,9 @@ const CommentList: React.FC = () => { showFilters ? 'bg-blue-100 text-blue-700' : 'hover:bg-gray-100' }`} > - + 筛选 - +
@@ -342,29 +816,32 @@ const CommentList: React.FC = () => { {/* Mobile comment list */}
- {comments.map((comment) => ( -
setSelectedComment(comment)} - > -
-
-
- - Facebook + {comments.map((comment) => { + const platformInfo = getPlatformIcon(comment.platform); + return ( +
setSelectedComment(comment)} + > +
+
+
+ {platformInfo.icon} + {platformInfo.name} +
-
-

{comment.content}

-
-
- {comment.author} +

{comment.content}

+
+
+ {comment.author} +
+ {comment.timestamp}
- {comment.timestamp}
-
- ))} + ); + })}
@@ -385,99 +862,102 @@ const CommentList: React.FC = () => { - {comments.map((comment) => ( - setSelectedComment(comment)} - > - -
-
- - - Facebook - + {comments.map((comment) => { + const platformInfo = getPlatformIcon(comment.platform); + return ( + setSelectedComment(comment)} + > + +
+
+ {platformInfo.icon} + + {platformInfo.name} + +
-
- - -
- {comment.content} -
- - -
-
{comment.author}
-
- - -
{comment.timestamp}
- - - {comment.language === 'zh-TW' && ( - - 繁中 - - )} - {comment.language === 'zh-CN' && ( - - 简中 - - )} - {comment.language === 'en' && ( - - EN - - )} - - - {comment.sentiment === 'positive' && ( - - - 正面 - - )} - {comment.sentiment === 'negative' && ( - - - 負面 - - )} - {comment.sentiment === 'neutral' && ( - - - 中性 - - )} - - - {comment.replyStatus === 'sent' && ( - - - 已回覆 - - )} - {comment.replyStatus === 'draft' && ( - - - 草稿 - - )} - {comment.replyStatus === 'none' && ( - - - 未回覆 - - )} - - - - - - ))} + + +
+ {comment.content} +
+ + +
+
{comment.author}
+
+ + +
{comment.timestamp}
+ + + {comment.language === 'zh-TW' && ( + + 繁中 + + )} + {comment.language === 'zh-CN' && ( + + 简中 + + )} + {comment.language === 'en' && ( + + EN + + )} + + + {comment.sentiment === 'positive' && ( + + + 正面 + + )} + {comment.sentiment === 'negative' && ( + + + 負面 + + )} + {comment.sentiment === 'neutral' && ( + + + 中性 + + )} + + + {comment.replyStatus === 'sent' && ( + + + 已回覆 + + )} + {comment.replyStatus === 'draft' && ( + + + 草稿 + + )} + {comment.replyStatus === 'none' && ( + + + 未回覆 + + )} + + + + + + ); + })}
@@ -489,6 +969,26 @@ const CommentList: React.FC = () => { setSelectedComment(null)} />
)} + + {/* 在评论列表的底部添加无限滚动加载指示器 */} +
+ {isLoadingMore && ( +
+ +
+ )} + + {!hasMore && comments.length === 0 && !loading && ( + + )} +
); }; diff --git a/web/src/components/PostList.tsx b/web/src/components/PostList.tsx index 721b90b..1f09ffd 100644 --- a/web/src/components/PostList.tsx +++ b/web/src/components/PostList.tsx @@ -294,6 +294,7 @@ const PostList: React.FC = ({ influencerId, projectId }) => { // Handle post click to view comments const handleViewComments = (postId: string) => { + console.log('Navigating to comments for post:', postId); navigate(`/comments?post_id=${postId}`); }; diff --git a/web/src/types.ts b/web/src/types.ts index ed60d7e..bfcc8f7 100644 --- a/web/src/types.ts +++ b/web/src/types.ts @@ -1,6 +1,6 @@ export interface Comment { id: string; - platform: 'facebook' | 'threads' | 'instagram' | 'linkedin' | 'xiaohongshu' | 'youtube'; + platform: 'facebook' | 'threads' | 'instagram' | 'linkedin' | 'xiaohongshu' | 'youtube' | 'twitter'; contentType?: 'post' | 'reel' | 'video' | 'short'; content: string; author: string; @@ -59,7 +59,7 @@ export interface ReplyPersona { export interface ReplyAccount { id: string; name: string; - platform: 'facebook' | 'threads' | 'instagram' | 'linkedin' | 'xiaohongshu' | 'youtube'; + platform: 'facebook' | 'threads' | 'instagram' | 'linkedin' | 'xiaohongshu' | 'youtube' | 'twitter'; avatar: string; role: 'admin' | 'moderator' | 'support'; } \ No newline at end of file