Changeset 99c1e45 for chapterx-frontend/src/pages/profile/ProfilePage.tsx
- Timestamp:
- 06/24/26 16:28:50 (11 days ago)
- Branches:
- main
- Children:
- a8f4a2d
- Parents:
- 0b502c2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapterx-frontend/src/pages/profile/ProfilePage.tsx
r0b502c2 r99c1e45 1 1 import React, { useState, useEffect } from 'react' 2 2 import { useParams, useNavigate } from 'react-router-dom' 3 import { BookOpen, Heart, Users, Calendar, MessageCircle, Eye } from 'lucide-react'3 import { BookOpen, Heart, Calendar, MessageCircle } from 'lucide-react' 4 4 import { useAuthStore } from '../../store/authStore' 5 5 import { useStoryStore } from '../../store/storyStore' … … 18 18 const navigate = useNavigate() 19 19 const { allUsers, currentUser, fetchAllUsers, updateUser } = useAuthStore() 20 const { stories, comments } = useStoryStore()20 const { stories, fetchStories } = useStoryStore() 21 21 const { addToast } = useUIStore() 22 22 const [tab, setTab] = useState<Tab>('stories') … … 27 27 28 28 useEffect(() => { 29 fetchStories() 29 30 if (allUsers.length === 0) { 30 31 setLoading(true) … … 74 75 const userStories = stories.filter(s => s.user_id === user.user_id && s.status === 'published') 75 76 const totalLikes = userStories.reduce((acc, s) => acc + s.total_likes, 0) 76 const totalViews = userStories.reduce((acc, s) => acc + s.total_views, 0) 77 const userComments = comments.filter(c => c.user_id === user.user_id) 77 const totalComments = userStories.reduce((acc, s) => acc + s.total_comments, 0) 78 78 const allGenres = [...new Set(userStories.flatMap(s => s.genres))] 79 79 … … 116 116 Joined {new Date(user.created_at).toLocaleDateString('en-US', { month: 'long', year: 'numeric' })} 117 117 </span> 118 <span className="flex items-center gap-1 text-slate-400 text-sm">119 <Users size={14} />120 {user.follower_count} followers · {user.following_count} following121 </span>122 118 </div> 123 119 </div> 124 120 125 121 {/* Stats */} 126 <div className="grid grid-cols- 2 sm:grid-cols-4gap-4 mb-8">122 <div className="grid grid-cols-3 gap-4 mb-8"> 127 123 {[ 128 124 { icon: <BookOpen size={16} className="text-indigo-400" />, value: userStories.length, label: 'Stories' }, 129 125 { icon: <Heart size={16} className="text-rose-400" />, value: totalLikes.toLocaleString(), label: 'Likes' }, 130 { icon: <Eye size={16} className="text-blue-400" />, value: totalViews.toLocaleString(), label: 'Views' }, 131 { icon: <MessageCircle size={16} className="text-amber-400" />, value: userComments.length, label: 'Comments' }, 126 { icon: <MessageCircle size={16} className="text-amber-400" />, value: totalComments, label: 'Comments' }, 132 127 ].map(s => ( 133 128 <div key={s.label} className="bg-slate-800 border border-slate-700 rounded-xl p-4 text-center"> … … 172 167 ) : ( 173 168 <div className="space-y-6"> 174 <div className="bg-slate-800 border border-slate-700 rounded-2xl p-6">175 <h3 className="text-white font-semibold mb-3">About</h3>176 <p className="text-slate-300">{user.bio || 'No bio provided.'}</p>177 </div>178 169 {allGenres.length > 0 && ( 179 170 <div className="bg-slate-800 border border-slate-700 rounded-2xl p-6">
Note:
See TracChangeset
for help on using the changeset viewer.
