Files
accounts-manager-web/components/accounts/stats-cards.tsx
Your Name 0b95ca36f1 Initial project setup with Next.js accounts manager
- Set up Next.js project structure
- Added UI components and styling
- Configured package dependencies
- Added feature documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 01:40:14 +08:00

93 lines
3.3 KiB
TypeScript

"use client";
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Database, TrendingUp, Users, Activity } from 'lucide-react';
import { StatsOverview } from '@/lib/types';
interface StatsCardsProps {
stats: StatsOverview | null;
loading?: boolean;
}
export function StatsCards({ stats, loading }: StatsCardsProps) {
if (loading) {
return (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
{Array.from({ length: 4 }).map((_, i) => (
<Card key={i}>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">...</CardTitle>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">--</div>
</CardContent>
</Card>
))}
</div>
);
}
if (!stats) {
return null;
}
return (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<Database className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{stats.totalAccounts}</div>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<TrendingUp className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{Object.keys(stats.platformSummary).length}</div>
<p className="text-xs text-muted-foreground">
{Object.entries(stats.platformSummary).slice(0, 3).map(([platform, count]) => (
`${platform}: ${count}`
)).join(', ')}
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<Users className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{Object.keys(stats.ownerSummary).length}</div>
<p className="text-xs text-muted-foreground">
{Object.entries(stats.ownerSummary).slice(0, 3).map(([owner, count]) => (
`${owner}: ${count}`
)).join(', ')}
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium"></CardTitle>
<Activity className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-green-600">
{stats.statusSummary.available || 0}
</div>
<p className="text-xs text-muted-foreground">
: {stats.statusSummary.locked || 0} |
: {stats.statusSummary.banned || 0}
</p>
</CardContent>
</Card>
</div>
);
}