import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { Dumbbell, User, Lock, ChevronRight, Calendar, Activity, ArrowLeft, Flame, CheckCircle2, Clock, Zap, Play, Pause, RotateCcw, LogOut } from 'lucide-react'; const App = () => { // --- STATO --- const [currentUser, setCurrentUser] = useState(null); const [view, setView] = useState('login'); const [selectedExercise, setSelectedExercise] = useState(null); // Salvataggio dati utenti (Bio e Goal) const [userConfigs, setUserConfigs] = useState({}); // --- DATABASE UTENTI --- const validUsers = useMemo(() => ({ "LEONARDO GREGO": "Leo.G011", "LEONARDO THIKA": "Leo.T011", "ETTORE GRIGOLLI": "3485541971" }), []); // --- DOMANDE (10 + 10) --- const bioQuestions = [ { id: 'weight', text: "Qual è il tuo peso attuale (kg)?", type: "number" }, { id: 'height', text: "Qual è la tua altezza (cm)?", type: "number" }, { id: 'age', text: "Quanti anni hai?", type: "number" }, { id: 'experience', text: "Livello di esperienza?", type: "select", options: ["Principiante", "Intermedio", "Avanzato"] }, { id: 'gender', text: "Genere?", type: "select", options: ["Uomo", "Donna"] }, { id: 'diet', text: "Stato della tua dieta?", type: "select", options: ["Mantenimento", "Ipercalorica", "Ipocalorica"] }, { id: 'meals', text: "Pasti al giorno?", type: "number" }, { id: 'sleep', text: "Ore di sonno medie?", type: "number" }, { id: 'injuries', text: "Hai infortuni?", type: "select", options: ["Nessuno", "Schiena", "Spalle", "Ginocchia"] }, { id: 'activity', text: "Attività lavorativa?", type: "select", options: ["Sedentaria", "Attiva", "Fisica"] } ]; const goalQuestions = [ { id: 'goal', text: "Qual è il tuo scopo?", type: "select", options: ["Massa Muscolare", "Dimagrimento", "Forza", "Resistenza"] }, { id: 'freq', text: "Giorni di allenamento/settimana?", type: "number" }, { id: 'duration', text: "Minuti per sessione?", type: "number" }, { id: 'intensity', text: "Intensità desiderata?", type: "select", options: ["Bassa", "Media", "Alta"] }, { id: 'focus', text: "Punto carente su cui lavorare?", type: "select", options: ["Braccia", "Gambe", "Core", "Spalle"] }, { id: 'cardio', text: "Ti piace il cardio?", type: "select", options: ["Sì", "No", "Solo fine sessione"] }, { id: 'equipment', text: "Dove ti alleni?", type: "select", options: ["Palestra", "Casa (Corpo Libero)", "Casa (Pesi)"] }, { id: 'supps', text: "Usi integratori?", type: "select", options: ["Sì", "No"] }, { id: 'tempo', text: "Preferenza esecuzione?", type: "select", options: ["Esplosiva", "Controllata", "Lenta"] }, { id: 'motivation', text: "Motivazione (1-10)?", type: "number" } ]; const exerciseDB = { "BRACCIA": ["Curl Bilanciere", "Hammer Curl", "Dips Panchetta", "Pushdown Fune", "French Press", "Curl Concentrato", "Spider Curl", "Estensioni Manubrio", "Diamond Pushups", "Zottman Curl", "Curl Panca Scott", "Kickback", "Preacher Curl", "Cavi Alti Bicipiti", "Curl Presa Inversa", "Tricipiti Corda", "Piegamenti Stretti", "Curl Elastico", "Skull Crushers", "Drag Curl"], "ADDOME": ["Crunch Terra", "Plank", "Leg Raises", "Russian Twist", "Mountain Climber", "V-Ups", "Bicycle Crunch", "Hollow Hold", "Side Plank", "Reverse Crunch", "Flutter Kicks", "Dead Bug", "Toe Touches", "Plank Jack", "Ab Wheel", "Windshield Wipers", "L-Sit", "Hanging Leg Raises", "Spider Plank", "Crunch ai Cavi"], "GAMBE": ["Squat Libero", "Affondi Camminati", "Leg Press", "Leg Extension", "Leg Curl", "Stacco Rumeno", "Calf Raise", "Bulgarian Split Squat", "Goblet Squat", "Sumo Squat", "Glute Bridge", "Step Up", "Jump Squat", "Affondi Laterali", "Hack Squat", "Hip Thrust", "Sissy Squat", "Nordic Curl", "Wall Sit", "Box Jump"], "ADDOME & DORSO": ["Trazioni", "Rematore Manubrio", "Lat Machine", "Pulley Basso", "Facepull", "Pull Over", "Bent Over Row", "T-Bar Row", "Chin Ups", "Superman Hold", "Panca Piana", "Pushups", "Dips Parallele", "Spinte Inclinate", "Croci Cavi", "Spinte Spalle", "Alzate Laterali", "Alzate Posteriori", "Shrugs", "Iperestensioni"] }; // --- LOGICA DI SUPPORTO --- const handleLogout = () => { setView('login'); setCurrentUser(null); }; // --- COMPONENTI --- const LoginForm = () => { const [name, setName] = useState(''); const [pass, setPass] = useState(''); const [localErr, setLocalErr] = useState(''); const onSubmit = (e) => { e.preventDefault(); const n = name.trim().toUpperCase(); if (validUsers[n] && validUsers[n] === pass) { setCurrentUser(n); const savedBio = localStorage.getItem(`bio_${n}`); setView(savedBio ? 'dashboard' : 'onboarding_bio'); } else { setLocalErr('Username o Password errati.'); } }; return (

LIQUIDFIT

setName(e.target.value)} />
setPass(e.target.value)} />
{localErr &&

{localErr}

}
); }; const Quiz = ({ questions, title, onComplete }) => { const [idx, setIdx] = useState(0); const [val, setVal] = useState(''); const q = questions[idx]; const handleNext = () => { const currentAnswers = JSON.parse(localStorage.getItem(`data_${currentUser}`) || '{}'); currentAnswers[q.id] = val; localStorage.setItem(`data_${currentUser}`, JSON.stringify(currentAnswers)); if (idx < questions.length - 1) { setIdx(idx + 1); setVal(''); } else { onComplete(); } }; return (

{title} • {idx + 1} / 10

{q.text}

{q.type === 'select' ? (
{q.options.map(o => ( ))}
) : ( setVal(e.target.value)} /> )}
); }; const Dashboard = () => (

LIQUIDFIT.

UTENTE: {currentUser}

{ const g = localStorage.getItem(`goal_${currentUser}`); setView(g ? 'daily' : 'onboarding_goal'); }} className="relative w-full p-8 rounded-[2.5rem] bg-gradient-to-br from-cyan-600 to-blue-800 mb-8 overflow-hidden cursor-pointer active:scale-[0.98] transition-all shadow-2xl shadow-cyan-900/30" >

DAILY

Piano 30 giorni creato per te

GIORNO 01

Categorie Esercizi

{Object.keys(exerciseDB).map(cat => (
setView(`cat_${cat}`)} className="p-6 rounded-[2rem] bg-white/5 border border-white/10 backdrop-blur-xl hover:bg-white/10 transition-all cursor-pointer group" >

{cat}

))}
); const WorkoutDetail = ({ exercise, onBack }) => { // Calcolo timer dinamico basato sul profilo e tipo esercizio const userData = JSON.parse(localStorage.getItem(`data_${currentUser}`) || '{}'); const isNovice = userData.experience === 'Principiante'; const baseTime = isNovice ? 90 : 60; // Più tempo per i principianti const [timeLeft, setTimeLeft] = useState(baseTime); const [isActive, setIsActive] = useState(false); useEffect(() => { let interval = null; if (isActive && timeLeft > 0) { interval = setInterval(() => { setTimeLeft((time) => time - 1); }, 1000); } else if (timeLeft === 0) { setIsActive(false); } return () => clearInterval(interval); }, [isActive, timeLeft]); const formatTime = (seconds) => { const mins = Math.floor(seconds / 60); const secs = seconds % 60; return `${mins}:${secs < 10 ? '0' : ''}${secs}`; }; return (

{exercise}

{/* TIMER COMPONENT */}

TIMER RECUPERO

{formatTime(timeLeft)}

SERIE

4

REP

12-15

Assicurati di mantenere il controllo durante la fase eccentrica. Il timer è impostato su {baseTime}s basato sul tuo profilo {userData.experience || 'Standard'}.

); }; const DailyView = () => { const days = Array.from({ length: 30 }, (_, i) => i + 1); return (

Evolution 30

{days.map(d => (
{ if(d===1) { setSelectedExercise("Full Body Activation"); setView('workout_detail'); }}} className={`p-6 rounded-[2rem] border transition-all relative overflow-hidden ${d === 1 ? 'bg-cyan-600 border-cyan-400 cursor-pointer shadow-lg shadow-cyan-500/20 active:scale-95' : 'bg-white/5 border-white/10 opacity-40'}`} >
GIORNO {d.toString().padStart(2, '0')} {d === 1 && }

{d % 5 === 0 ? 'Rest & Recovery' : 'Hypertrophy Session'}

{d === 1 &&

6 Esercizi • Timer Adattivo

}
))}
); }; const CategoryList = ({ category }) => (

{category}

{exerciseDB[category].map((ex, i) => (
{ setSelectedExercise(ex); setView('workout_detail'); }} className="p-5 bg-white/5 border border-white/5 rounded-2xl flex items-center justify-between hover:border-cyan-500/30 transition-all cursor-pointer group active:scale-[0.98]" >
{(i+1).toString().padStart(2, '0')} {ex}
))}
); // --- ROUTER --- if (view === 'login') return ; if (view === 'onboarding_bio') return { localStorage.setItem(`bio_${currentUser}`, 'done'); setView('dashboard'); }} />; if (view === 'onboarding_goal') return { localStorage.setItem(`goal_${currentUser}`, 'done'); setView('daily'); }} />; if (view === 'dashboard') return ; if (view === 'daily') return ; if (view === 'workout_detail') return setView('dashboard')} />; if (view.startsWith('cat_')) return ; return ; }; export default App;