import React, { useState, useEffect } from 'react';
import {
Shield, Zap, DollarSign, Menu, X, CreditCard, Star, Gift,
ArrowRight, CheckCircle, Play, Lock, User, LayoutDashboard,
Briefcase, LogOut, BarChart3, Users, PlusCircle, Smartphone, FileText, MapPin, Phone
} from 'lucide-react';
// --- IDENTIDAD VISUAL & LOGO ---
const Logo = ({ size = "w-12 h-12", showText = false, colorText = "text-[#0B1C3C]" }) => (
);
// --- DATOS MOCK ---
const MISSIONS = [
{ id: 1, title: "Ver Video Promocional", reward: 0.05, type: "video", partner: "AdNetwork", duration: "30s" },
{ id: 2, title: "Like a Barbería El Pepe", reward: 0.15, type: "social", partner: "Barbería El Pepe", duration: "Instant" },
{ id: 3, title: "Encuesta Financiera", reward: 0.50, type: "survey", partner: "Banco Local", duration: "5 min" },
{ id: 4, title: "Seguir a Pizzería Don Juan", reward: 0.10, type: "social", partner: "Pizzería Don Juan", duration: "Instant" },
{ id: 5, title: "Instalar Juego 'Warriors'", reward: 1.20, type: "download", partner: "GameStudio", duration: "2 min" },
];
const COUPONS = [
{ id: 1, title: "2x1 en Hamburguesas", store: "Burger King", discount: "50%", cost: 0, img: "🍔" },
{ id: 2, title: "Corte de Cabello", store: "Barbería El Pepe", discount: "-20%", cost: 10, img: "💈" },
{ id: 3, title: "Pizza Familiar", store: "Don Juan", discount: "$5 OFF", cost: 50, img: "🍕" },
];
// --- APP COMPONENT ---
export default function App() {
// Estados Globales
const [authView, setAuthView] = useState('login'); // login, register, app
const [userRole, setUserRole] = useState('guest'); // guest, free, elite, business
const [view, setView] = useState('dashboard');
const [balance, setBalance] = useState(0.00);
const [showAd, setShowAd] = useState(false);
const [sidebarOpen, setSidebarOpen] = useState(false); // Mobile sidebar toggle
// ESTADO DE VALIDACIÓN DE USUARIO (KYC)
const [isVerified, setIsVerified] = useState(false);
const [showVerificationModal, setShowVerificationModal] = useState(false);
const [pendingAction, setPendingAction] = useState(null); // Para guardar qué quería hacer el usuario antes de validar
// Lógica de navegación y anuncios
const handleViewChange = (newView) => {
// Simulación de "Regla de Actividad" (Anuncio obligatorio para usuarios Free)
if (userRole === 'free' && Math.random() > 0.7 && newView !== 'elite') {
setShowAd(true);
setTimeout(() => setShowAd(false), 3500);
}
setView(newView);
setSidebarOpen(false); // Cerrar sidebar en móvil al navegar
};
const login = (role) => {
setUserRole(role);
setAuthView('app');
setView('dashboard');
// Simulamos que el usuario Elite ya está verificado, pero el Free debe hacerlo
if (role === 'elite') {
setBalance(15.50);
setIsVerified(true);
} else {
setBalance(0.00);
setIsVerified(false); // Usuario nuevo empieza sin verificar
}
if (role === 'business') setBalance(500.00);
};
const logout = () => {
setAuthView('login');
setUserRole('guest');
setBalance(0);
setIsVerified(false);
};
// Función Guardián: Verifica si el usuario puede realizar acciones críticas
const checkVerification = (actionCallback) => {
if (isVerified || userRole === 'business') {
actionCallback();
} else {
setPendingAction(() => actionCallback); // Guardamos la acción para ejecutarla después de validar
setShowVerificationModal(true);
}
};
const handleVerificationSubmit = (e) => {
e.preventDefault();
// Aquí iría la lógica de envío al backend
setIsVerified(true);
setShowVerificationModal(false);
alert("¡Identidad Validada con Éxito!");
// Ejecutar la acción que estaba pendiente (ej: solicitar préstamo o completar misión)
if (pendingAction) {
pendingAction();
setPendingAction(null);
}
};
// --- SUB-COMPONENTES DE UI ---
const SidebarItem = ({ icon: Icon, label, active, onClick, color }) => (
{label}
);
const StatCard = ({ title, value, subtext, icon: Icon, colorClass }) => (
{title}
{value}
{subtext &&
{subtext}
}
{/* Decoración fondo */}
);
// --- VISTAS DE AUTENTICACIÓN (LOGIN/REGISTER) ---
if (authView !== 'app') {
return (
{/* Fondo decorativo */}
{/* Lado Izquierdo (Visual) */}
Tu tiempo vale Oro .
Únete al ecosistema financiero donde pedir prestado, ganar y ahorrar es una sola misión.
Préstamos Rápidos
Ingresos por Tareas
Descuentos Reales
{/* Lado Derecho (Formulario) */}
{authView === 'login' ? 'Iniciar Sesión' : 'Crear Cuenta'}
setAuthView(authView === 'login' ? 'register' : 'login')}
className="text-sm text-blue-600 font-bold hover:underline"
>
{authView === 'login' ? 'Registrarse' : 'Entrar'}
);
}
// --- ESTRUCTURA PRINCIPAL DE LA APP (DASHBOARD) ---
const isBusiness = userRole === 'business';
return (
{/* 1. SIDEBAR (Navegación Desktop & Mobile Drawer) */}
{/* Overlay para móvil */}
{sidebarOpen && (
setSidebarOpen(false)}
>
)}
{/* 2. CONTENIDO PRINCIPAL (Main Area) */}
{/* Mobile Header */}
{/* VIEW: DASHBOARD USUARIO */}
{view === 'dashboard' && !isBusiness && (
{/* Stats Grid */}
{/* Promo Banner */}
¿Necesitas dinero urgente?
Nuestra red de financieras tiene nuevas ofertas para ti. Si no calificas, te pagamos por intentarlo.
handleViewChange('loan')} className="bg-[#39FF14] text-[#0B1C3C] px-6 py-3 rounded-xl font-bold hover:scale-105 transition shadow-lg shadow-green-500/30">
Solicitar Préstamo
{/* Recent Missions */}
Misiones Recomendadas
handleViewChange('missions')} className="text-sm text-blue-600 font-bold hover:underline">Ver todas
{MISSIONS.slice(0, 3).map(m => (
handleViewChange('missions')}>
{m.type}
+${userRole === 'elite' ? (m.reward * 1.1).toFixed(2) : m.reward.toFixed(2)}
{m.title}
{m.partner} • {m.duration}
))}
)}
{/* VIEW: PRÉSTAMOS (Loan Simulator) */}
{view === 'loan' && (
Simulador de Préstamo
Encuentra la mejor oferta en segundos.
checkVerification(() => alert("¡Solicitud enviada a revisión! Te contactaremos en breve."))}
className="w-full bg-[#0B1C3C] text-white py-4 rounded-xl font-bold shadow-xl hover:bg-[#152a55] transition mb-4"
>
SOLICITAR AHORA
Al solicitar, aceptas nuestros términos y condiciones. Tu información será compartida con nuestros aliados financieros.
)}
{/* VIEW: MISIONES */}
{view === 'missions' && (
{MISSIONS.map((m, idx) => (
{m.type === 'video' ?
:
}
{m.title}
{m.partner}
•
{m.duration}
+${userRole === 'elite' ? (m.reward * 1.1).toFixed(2) : m.reward.toFixed(2)}
{userRole === 'free' &&
${(m.reward * 1.1).toFixed(2)}
}
checkVerification(() => {
setBalance(prev => prev + (userRole === 'elite' ? m.reward * 1.1 : m.reward));
alert("¡Recompensa acreditada!");
})}
className="mt-1 bg-[#0B1C3C] text-white text-xs px-3 py-1 rounded hover:bg-blue-900 transition"
>
Completar
))}
)}
{/* VIEW: ELITE (SUSCRIPCIÓN) */}
{view === 'elite' && (
MISIÓN ELITE
Desbloquea el máximo potencial de tus ingresos.
Turbo Ganancias
Gana un 10% extra permanente en todas las misiones que completes.
Cero Publicidad
Elimina los anuncios obligatorios y navega sin interrupciones.
POPULAR
Suscripción Mensual
$1.50 /mes
{userRole === 'elite' ? (
PLAN ACTIVO
) : (
{ setUserRole('elite'); setBalance(prev => prev - 1.50); alert("¡Bienvenido al Nivel Elite!"); }} className="w-full bg-[#39FF14] hover:bg-[#32d612] text-[#0B1C3C] py-3 rounded-lg font-bold transition">
ACTIVAR AHORA
)}
Se descuenta automáticamente de tu saldo.
)}
{/* VIEW: BUSINESS DASHBOARD (B2B) */}
{isBusiness && view === 'dashboard' && (
Panel de Negocio
Campañas Activas
Nueva Campaña
Nombre
Tipo
Progreso
Estado
Promo Verano 2x1
Cupón QR
Activa
Seguidores Instagram
Social Task
Pausada
)}
{/* 3. MOBILE BOTTOM NAV (Solo visible en pantallas pequeñas y usuarios NO negocio) */}
{!isBusiness && (
handleViewChange('dashboard')} className={`flex flex-col items-center ${view === 'dashboard' ? 'text-[#0B1C3C]' : 'text-gray-400'}`}>
handleViewChange('missions')} className={`flex flex-col items-center ${view === 'missions' ? 'text-[#0B1C3C]' : 'text-gray-400'}`}>
handleViewChange('loan')} className="flex flex-col items-center -mt-8 bg-[#39FF14] p-4 rounded-full shadow-lg border-4 border-gray-50 text-[#0B1C3C]">
handleViewChange('coupons')} className={`flex flex-col items-center ${view === 'coupons' ? 'text-[#0B1C3C]' : 'text-gray-400'}`}>
handleViewChange('elite')} className={`flex flex-col items-center ${view === 'elite' ? 'text-[#B8860B]' : 'text-gray-400'}`}>
)}
{/* AD INTERSTITIAL SIMULATION */}
{showAd && (
Juego de Guerra
El mejor juego de estrategia del año.
INSTALAR AHORA
El anuncio cerrará en 3 segundos...
¿Odias esperar?
{ setShowAd(false); handleViewChange('elite'); }} className="text-[#FFD700] font-bold underline">Hazte Elite por $1.50
)}
{/* MODAL DE VALIDACIÓN DE CUENTA (KYC) */}
{showVerificationModal && (
setShowVerificationModal(false)} className="absolute top-4 right-4 text-white/70 hover:text-white">
Validación de Identidad
Requerido para préstamos y retiros (KYC).
)}
);
}