"use client"; import React, { useEffect, useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; const DIAGNOSTICS = [ "SOLAR PANEL DİZİLERİ SENKRONİZE EDİLİYOR...", "RÜZGAR TRÜBİN KOMPANSATÖRLERİ DENGELENİYOR...", "KOJENERASYON OPTİMİZASYON KATI AKTİFLEŞTİRİLİYOR...", "YEŞİL DÖNÜŞÜM KARBON AĞI YAPILANDIRILIYOR...", "SCENERJİ ENERJİ AKIŞI STABİL DURUMA GETİRİLDİ.", ]; export default function Preloader({ onComplete }: { onComplete: () => void }) { const [progress, setProgress] = useState(0); const [diagnosticText, setDiagnosticText] = useState(DIAGNOSTICS[0]); const [isVisible, setIsVisible] = useState(true); useEffect(() => { let currentProgress = 0; const duration = 2400; // 2.4 seconds total preloader time const intervalTime = 20; const step = 100 / (duration / intervalTime); const timer = setInterval(() => { currentProgress += step; if (currentProgress >= 100) { currentProgress = 100; clearInterval(timer); setTimeout(() => { setIsVisible(false); setTimeout(onComplete, 800); // Allow curtain reveal animation to complete }, 500); } setProgress(Math.floor(currentProgress)); // Update diagnostic text based on progress const diagIndex = Math.min( Math.floor((currentProgress / 100) * DIAGNOSTICS.length), DIAGNOSTICS.length - 1 ); setDiagnosticText(DIAGNOSTICS[diagIndex]); }, intervalTime); return () => clearInterval(timer); }, [onComplete]); return ( {isVisible && ( {/* Subtle decorative grid in preloader */}
{/* Tech Logo / Icon */}
SCENERJİ SYSTEM v2.6.0
{/* Diagnostic Logs */}
[SİSTEM TEŞHİS KÜTÜPHANESİ] {diagnosticText}
{/* Progress Counter & Bar */}
ENERJİ AĞI KALİBRASYONU {progress}%
KURULUM: AYRIS TECH LOKASYON: TÜRKİYE
)} ); }