source: chapterx-frontend/src/components/admin/PlatformStats.tsx@ b62cefc

main
Last change on this file since b62cefc was b62cefc, checked in by kikisrbinoska <srbinoskakristina07@…>, 4 months ago

Added frontend and imporoved AI Suggestions service

  • Property mode set to 100644
File size: 2.2 KB
Line 
1import React from 'react'
2import { Users, BookOpen, FileText, Heart, Eye, MessageCircle } from 'lucide-react'
3import { useAuthStore } from '../../store/authStore'
4import { useStoryStore } from '../../store/storyStore'
5
6export const PlatformStats: React.FC = () => {
7 const { allUsers } = useAuthStore()
8 const { stories, comments } = useStoryStore()
9
10 const totalViews = stories.reduce((acc, s) => acc + s.total_views, 0)
11 const totalLikes = stories.reduce((acc, s) => acc + s.total_likes, 0)
12 const published = stories.filter(s => s.status === 'published').length
13
14 const stats = [
15 { icon: <Users size={24} className="text-blue-300" />, label: 'Total Users', value: allUsers.length, color: 'bg-blue-500/20', change: '+12 this month' },
16 { icon: <BookOpen size={24} className="text-violet-300" />, label: 'Total Stories', value: stories.length, color: 'bg-violet-500/20', change: `${published} published` },
17 { icon: <FileText size={24} className="text-emerald-300" />, label: 'Comments', value: comments.length, color: 'bg-emerald-500/20', change: 'Platform-wide' },
18 { icon: <Heart size={24} className="text-rose-300" />, label: 'Total Likes', value: totalLikes.toLocaleString(), color: 'bg-rose-500/20', change: 'Across all stories' },
19 { icon: <Eye size={24} className="text-amber-300" />, label: 'Total Views', value: totalViews.toLocaleString(), color: 'bg-amber-500/20', change: 'All time' },
20 { icon: <MessageCircle size={24} className="text-cyan-300" />, label: 'Writers', value: allUsers.filter(u => u.role === 'writer').length, color: 'bg-cyan-500/20', change: 'Active creators' },
21 ]
22
23 return (
24 <div className="grid grid-cols-2 md:grid-cols-3 gap-4">
25 {stats.map(stat => (
26 <div key={stat.label} className="bg-slate-800 border border-slate-700 rounded-2xl p-6">
27 <div className={`w-12 h-12 rounded-xl ${stat.color} flex items-center justify-center mb-4`}>
28 {stat.icon}
29 </div>
30 <p className="text-3xl font-bold text-white mb-1">{stat.value}</p>
31 <p className="text-slate-400 text-sm font-medium">{stat.label}</p>
32 <p className="text-slate-600 text-xs mt-1">{stat.change}</p>
33 </div>
34 ))}
35 </div>
36 )
37}
Note: See TracBrowser for help on using the repository browser.