Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | 10x 10x 10x 10x 10x 10x 40x 3x 16x | import { Link } from "@tanstack/react-router";
import { Store, FolderKanban, TrendingUp, Clock } from "lucide-react";
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "../../components/ui/card";
import { StatusBadge } from "../../components/ui/status-badge";
import { Skeleton } from "../../components/ui/skeleton";
import { EmptyState } from "../../components/ui/empty-state";
import { useAdminDashboard } from "../../hooks/queries/useAdminQueries";
export function AdminDashboardPage() {
const { data, isLoading } = useAdminDashboard();
const stats = data?.stats ?? null;
const recentPros = data?.recentPros ?? [];
const pendingPros = stats?.pendingPros ?? 0;
const statCards = [
{
name: "Total Pros",
value: stats?.totalPros ?? "-",
subtext: `${stats?.publishedPros ?? 0} published`,
icon: Store,
href: "/admin/pros",
},
{
name: "Pros pending publish",
value: pendingPros,
subtext:
pendingPros === 0
? "No pros waiting for approval"
: "Set status to Published to approve",
icon: Clock,
href: "/admin/pros?status=draft",
highlight: pendingPros > 0,
},
{
name: "Total Projects",
value: stats?.totalProjects ?? "-",
subtext: `${stats?.publishedProjects ?? 0} published`,
icon: FolderKanban,
href: "/admin/projects",
},
{
name: "Conversion Rate",
value: "-",
subtext: "Coming soon",
icon: TrendingUp,
href: "/admin",
},
];
return (
<div className="space-y-8">
{/* Header */}
<div>
<h1 className="text-2xl font-bold text-foreground-default">
Admin Dashboard
</h1>
<p className="mt-1 text-foreground-muted">
Overview of all pros and projects.
</p>
</div>
{/* Stats Grid */}
<div className="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-4">
{statCards.map((stat) => (
<Link key={stat.name} to={stat.href}>
<Card
className={`hover:shadow-md transition-shadow cursor-pointer ${
stat.highlight
? "border-warning ring-1 ring-warning/30"
: ""
}`}
>
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-sm font-medium text-foreground-muted">
{stat.name}
</CardTitle>
<stat.icon
className={`h-5 w-5 ${
stat.highlight ? "text-warning" : "text-foreground-subtle"
}`}
/>
</CardHeader>
<CardContent>
<div
className={`text-2xl font-bold ${
stat.highlight ? "text-warning" : ""
}`}
>
{isLoading ? <Skeleton className="h-8 w-16" /> : stat.value}
</div>
<p className="text-xs text-foreground-muted">
{stat.subtext}
</p>
</CardContent>
</Card>
</Link>
))}
</div>
{/* Recent Data */}
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
{/* Recent Pros */}
<Card>
<CardHeader>
<CardTitle className="text-lg">Recent Pros</CardTitle>
</CardHeader>
<CardContent>
{isLoading ? (
<div className="space-y-4">
{[1, 2, 3].map((i) => (
<div
key={i}
className="flex items-center justify-between border-b pb-4 last:border-0"
>
<div className="space-y-2">
<Skeleton className="h-4 w-32" />
<Skeleton className="h-3 w-24" />
</div>
</div>
))}
</div>
) : recentPros.length === 0 ? (
<EmptyState
icon={Store}
title="No pros yet"
className="py-8"
/>
) : (
<div className="space-y-4">
{recentPros.map((pro) => (
<Link
key={pro.id}
to={`/admin/pros/${pro.id}`}
className="flex items-center justify-between border-b pb-4 last:border-0 hover:bg-background-muted -mx-2 px-2 py-1 rounded"
>
<div>
<p className="font-medium text-foreground-default">
{pro.businessName}
</p>
<p className="text-sm text-foreground-muted">
{pro.primaryLocality
? `${pro.primaryLocality.name}, ${pro.primaryLocality.city}`
: "No location set"}
</p>
</div>
<StatusBadge status={pro.status} />
</Link>
))}
<Link
to="/admin/pros"
className="block text-center text-sm text-primary-600 hover:text-primary-700 pt-2"
>
View all pros →
</Link>
</div>
)}
</CardContent>
</Card>
</div>
</div>
);
}
|