import { motion } from "framer-motion";
import { Link, useLocation } from "wouter";
import { useQuery } from "@tanstack/react-query";
import { useAuth } from "@/lib/auth";
import { getIcon } from "@/lib/iconMap";
import {
Users, FileCode, Shield, Activity, LogOut,
BarChart3, User, Globe, Key, Award, Star, Trophy
} from "lucide-react";
export default function AdminAchievements() {
const { user, logout } = useAuth();
const [, setLocation] = useLocation();
const { data: achievements, isLoading } = useQuery({
queryKey: ["achievements"],
queryFn: async () => {
const res = await fetch("/api/achievements");
if (!res.ok) throw new Error("Failed to fetch achievements");
return res.json();
},
});
const handleLogout = async () => {
await logout();
setLocation("/");
};
const getRarityColor = (rarity: string) => {
switch (rarity?.toLowerCase()) {
case 'legendary': return 'border-yellow-500 bg-yellow-500/10';
case 'epic': return 'border-purple-500 bg-purple-500/10';
case 'rare': return 'border-blue-500 bg-blue-500/10';
case 'uncommon': return 'border-green-500 bg-green-500/10';
default: return 'border-white/10 bg-white/5';
}
};
return (
Achievements
{achievements?.length || 0} achievements configured
{isLoading ? (
Loading...
) : achievements?.length === 0 ? (
No achievements found
) : (
achievements?.map((achievement: any) => (
{getIcon(achievement.icon)}
{achievement.name}
{achievement.description}
XP
+{achievement.xp_reward || 0}
Points
+{achievement.points_reward || 0}
Rarity
{achievement.rarity || 'common'}
{achievement.category && (
{achievement.category}
)}
))
)}
);
}
function Sidebar({ user, onLogout, active }: { user: any; onLogout: () => void; active: string }) {
return (
{user?.username}
{user?.isAdmin ? "Administrator" : "Member"}
);
}
function NavItem({ icon, label, href, active = false }: { icon: React.ReactNode; label: string; href: string; active?: boolean }) {
return (
{icon}
{label}
);
}