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/writer/WriterDashboard.tsx

    r0b502c2 r99c1e45  
    1 import React from 'react'
     1import React, { useEffect } from 'react'
    22import { useNavigate } from 'react-router-dom'
    3 import { Plus, BookOpen, Eye, Heart, MessageCircle, TrendingUp, Bell } from 'lucide-react'
     3import { Plus, BookOpen, Heart, MessageCircle, TrendingUp, Bell } from 'lucide-react'
    44import { useAuthStore } from '../../store/authStore'
    55import { useStoryStore } from '../../store/storyStore'
     
    2222  const navigate = useNavigate()
    2323  const { currentUser } = useAuthStore()
    24   const { stories, collaborations } = useStoryStore()
     24  const { stories, collaborations, fetchStories } = useStoryStore()
    2525  const { notifications } = useNotificationStore()
     26
     27  useEffect(() => { fetchStories() }, [])
    2628
    2729  if (!currentUser) return null
     
    3436  const published = myStories.filter(s => s.status === 'published')
    3537  const drafts = myStories.filter(s => s.status === 'draft')
    36   const totalViews = myStories.reduce((acc, s) => acc + s.total_views, 0)
    3738  const totalLikes = myStories.reduce((acc, s) => acc + s.total_likes, 0)
    3839
     
    5657
    5758      {/* Stats */}
    58       <div className="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
     59      <div className="grid grid-cols-2 lg:grid-cols-3 gap-4 mb-8">
    5960        {[
    6061          { icon: <BookOpen size={20} className="text-indigo-300" />, label: 'Total Stories', value: myStories.length, sub: `${published.length} published`, color: 'bg-indigo-500/20' },
    61           { icon: <Eye size={20} className="text-blue-300" />, label: 'Total Views', value: totalViews.toLocaleString(), sub: 'All time', color: 'bg-blue-500/20' },
    6262          { icon: <Heart size={20} className="text-rose-300" />, label: 'Total Likes', value: totalLikes.toLocaleString(), sub: 'Across all stories', color: 'bg-rose-500/20' },
    6363          { icon: <TrendingUp size={20} className="text-emerald-300" />, label: 'Drafts', value: drafts.length, sub: 'In progress', color: 'bg-emerald-500/20' },
     
    108108                      <div className="flex items-center gap-3 text-slate-500 text-xs">
    109109                        {isCollab && <span className="text-slate-500">by {story.author_username}</span>}
    110                         <span className="flex items-center gap-1"><Eye size={11} /> {story.total_views.toLocaleString()}</span>
    111110                        <span className="flex items-center gap-1"><Heart size={11} /> {story.total_likes}</span>
    112111                        <span className="flex items-center gap-1"><MessageCircle size={11} /> {story.total_comments}</span>
     
    155154            <TrendingUp size={18} className="text-indigo-400" />
    156155            <h2 className="font-serif text-xl font-bold text-white">Analytics</h2>
    157             <span className="text-slate-500 text-sm">(Story: The Chronicles of Eldoria)</span>
    158156          </div>
    159           <StoryAnalytics />
     157          <StoryAnalytics stories={myStories} />
    160158        </div>
    161159      )}
Note: See TracChangeset for help on using the changeset viewer.