'use client' import { motion } from 'framer-motion' import { useInView } from 'framer-motion' import { useRef, useState, useEffect } from 'react' import { Lock, Clock, Ban, CheckCircle } from 'lucide-react' import BackgroundAnimations from '@/components/BackgroundAnimations' export default function Stats() { const ref = useRef(null) const isInView = useInView(ref, { once: true, margin: '-100px' }) // Générer un nombre aléatoire pour les tentatives bloquées // Initialiser à 0 pour éviter les erreurs d'hydratation (serv/client doivent correspondre) const [blockedAttempts, setBlockedAttempts] = useState(0) // Mettre à jour le nombre aléatoire après le montage et périodiquement useEffect(() => { // Générer le premier nombre aléatoire uniquement côté client const randomValue = Math.floor(Math.random() * 10000) setBlockedAttempts(randomValue) // Mettre à jour le nombre aléatoire périodiquement pour donner un effet dynamique const interval = setInterval(() => { // Générer un nouveau nombre aléatoire entre 0 et 9999 const newRandomValue = Math.floor(Math.random() * 10000) setBlockedAttempts(newRandomValue) }, 5000) // Mise à jour toutes les 5 secondes return () => clearInterval(interval) }, []) const stats = [ { icon: Clock, value: '99.9', unit: '%', label: 'Uptime', gradient: 'from-blue-500 to-cyan-500', isDynamic: false }, { icon: Lock, value: '256', unit: ' Bit', label: 'Encryption', gradient: 'from-security-accent to-green-500', isDynamic: false }, { icon: Clock, value: '24', unit: '/7', label: 'Support', gradient: 'from-purple-500 to-pink-500', isDynamic: false }, { icon: Ban, value: blockedAttempts.toString(), label: 'Tentatives bloquées', gradient: 'from-red-500 to-orange-500', isDynamic: true }, { icon: CheckCircle, value: '100', unit: '%', label: 'Conformité RGPD', gradient: 'from-emerald-500 to-teal-500', isDynamic: false }, ] return (
{stats.map((stat, index) => ( {/* Gradient Background on Hover */}
{stat.isDynamic ? blockedAttempts.toString() : (isInView ? stat.value : '0')} {stat.unit && ( {stat.unit} )}
{stat.label}
))}
) }