Ignore:
Timestamp:
06/24/26 16:28:50 (11 days ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Children:
a8f4a2d
Parents:
0b502c2
Message:

Fixed writer section and admin management

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapterx-frontend/src/pages/profile/ProfilePage.tsx

    r0b502c2 r99c1e45  
    11import React, { useState, useEffect } from 'react'
    22import { useParams, useNavigate } from 'react-router-dom'
    3 import { BookOpen, Heart, Users, Calendar, MessageCircle, Eye } from 'lucide-react'
     3import { BookOpen, Heart, Calendar, MessageCircle } from 'lucide-react'
    44import { useAuthStore } from '../../store/authStore'
    55import { useStoryStore } from '../../store/storyStore'
     
    1818  const navigate = useNavigate()
    1919  const { allUsers, currentUser, fetchAllUsers, updateUser } = useAuthStore()
    20   const { stories, comments } = useStoryStore()
     20  const { stories, fetchStories } = useStoryStore()
    2121  const { addToast } = useUIStore()
    2222  const [tab, setTab] = useState<Tab>('stories')
     
    2727
    2828  useEffect(() => {
     29    fetchStories()
    2930    if (allUsers.length === 0) {
    3031      setLoading(true)
     
    7475  const userStories = stories.filter(s => s.user_id === user.user_id && s.status === 'published')
    7576  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)
    7878  const allGenres = [...new Set(userStories.flatMap(s => s.genres))]
    7979
     
    116116            Joined {new Date(user.created_at).toLocaleDateString('en-US', { month: 'long', year: 'numeric' })}
    117117          </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} following
    121           </span>
    122118        </div>
    123119      </div>
    124120
    125121      {/* Stats */}
    126       <div className="grid grid-cols-2 sm:grid-cols-4 gap-4 mb-8">
     122      <div className="grid grid-cols-3 gap-4 mb-8">
    127123        {[
    128124          { icon: <BookOpen size={16} className="text-indigo-400" />, value: userStories.length, label: 'Stories' },
    129125          { 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' },
    132127        ].map(s => (
    133128          <div key={s.label} className="bg-slate-800 border border-slate-700 rounded-xl p-4 text-center">
     
    172167      ) : (
    173168        <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>
    178169          {allGenres.length > 0 && (
    179170            <div className="bg-slate-800 border border-slate-700 rounded-2xl p-6">
Note: See TracChangeset for help on using the changeset viewer.