import React, { useState, useEffect } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { Medal, Star, Shield, Award } from "lucide-react"; interface ReputationSystemProps { actionCount: number; // Trigger updates based on actions } const ReputationSystem: React.FC = ({ actionCount }) => { // Persist XP in local storage for demo purposes const [xp, setXp] = useState(() => parseInt(localStorage.getItem("ride_xp") || "0")); const [level, setLevel] = useState(1); const [showLevelUp, setShowLevelUp] = useState(false); useEffect(() => { // Calculate Level: Level 1 = 0-100xp, Level 2 = 101-300xp, etc. const newLevel = Math.floor(Math.sqrt(xp / 100)) + 1; if (newLevel > level) { setShowLevelUp(true); setTimeout(() => setShowLevelUp(false), 3000); } setLevel(newLevel); }, [xp]); // Update XP when actionCount increments (parent tells us something happened) useEffect(() => { if (actionCount > 0) { const gain = Math.floor(Math.random() * 20) + 10; const newXp = xp + gain; setXp(newXp); localStorage.setItem("ride_xp", newXp.toString()); } }, [actionCount]); const getRankTitle = (lvl: number) => { if (lvl < 2) return "Novice Observer"; if (lvl < 5) return "Data Scout"; if (lvl < 10) return "Pattern Analyst"; return "Neural Architect"; }; return (
{/* Level Up Notification */} {showLevelUp && (

LEVEL UP!

Level {level}

New privileges accessing...

)}
{level}
{getRankTitle(level)}
); }; export default ReputationSystem;