import { useState } from 'react' import vgn1 from '../assets/virtualguardednetwork1.png' import vgn2 from '../assets/virtualguardednetwork2.png' import './VirtualGuardedNetworkTour.css' type TourStep = { id: string title: string description: string image: string region: { leftPct: number; topPct: number; widthPct: number; heightPct: number } popupPosition?: { leftPct?: number; topPct?: number; rightPct?: number; bottomPct?: number } } const vgnSteps: TourStep[] = [ { id: 'overview', title: 'Virtual Guarded Network (VGN) Overview', description: 'VGN bölümüne hoş geldiniz! Zincirler, erişim, MFA politikaları ve logları buradan yönetebilirsiniz.', image: vgn1, region: { leftPct: 0, topPct: 0, widthPct: 100, heightPct: 100 }, popupPosition: { rightPct: 35, topPct: 60 }, }, { id: 'chain-header', title: 'Chain Header & Controls', description: 'Zincirin adı, mod, MTU, DHCP ve routing gibi meta veriler bu başlıkta yer alır. Arama ve Add New ile yeni zincirler ekleyebilirsiniz.', image: vgn1, region: { leftPct: 15, topPct: 2, widthPct: 84, heightPct: 10 }, popupPosition: { rightPct: 2, topPct: 14 }, }, { id: 'chain-flow', title: 'Chain Flow', description: 'Kullanıcı girişinden başlayıp, iç düğümler ve Internet Exit\'e giden görsel akış burada gösterilir.', image: vgn1, region: { leftPct: 15, topPct: 16, widthPct: 84, heightPct: 43 }, popupPosition: { leftPct: 15, bottomPct: 20 }, }, { id: 'actions-and-policies', title: 'Actions & Policies', description: 'Sağ üstte yer alan VGN Chains, Access, MFA Policies ve Logs butonları ile politikaları ve günlükleri yönetebilirsiniz.', image: vgn2, region: { leftPct: 71, topPct: 7, widthPct: 24, heightPct: 7 }, popupPosition: { rightPct: 8, topPct: 16 }, }, ] type VirtualGuardedNetworkTourProps = { autoStart?: boolean onClose?: () => void } export default function VirtualGuardedNetworkTour({ autoStart = false, onClose }: VirtualGuardedNetworkTourProps) { const [isModalOpen, setIsModalOpen] = useState(autoStart) const [currentStep, setCurrentStep] = useState(0) const [isTransitioning, setIsTransitioning] = useState(false) const [isModalAnimating, setIsModalAnimating] = useState(false) const [transitionDirection, setTransitionDirection] = useState<'next' | 'prev'>('next') const handleStartTour = () => { setIsModalOpen(true) setCurrentStep(0) } const handleClose = () => { setIsModalAnimating(true) if (onClose) onClose() setTimeout(() => { setIsModalOpen(false) setCurrentStep(0) setIsTransitioning(false) setTimeout(() => setIsModalAnimating(false), 50) }, 250) } const handleNext = () => { if (currentStep < vgnSteps.length - 1) { setTransitionDirection('next') setIsTransitioning(true) setTimeout(() => { setCurrentStep(currentStep + 1) setTimeout(() => setIsTransitioning(false), 50) }, 300) } } const handlePrevious = () => { if (currentStep > 0) { setTransitionDirection('prev') setIsTransitioning(true) setTimeout(() => { setCurrentStep(currentStep - 1) setTimeout(() => setIsTransitioning(false), 50) }, 300) } } const handleStepClick = (stepIndex: number) => { if (stepIndex !== currentStep) { setTransitionDirection(stepIndex > currentStep ? 'next' : 'prev') setIsTransitioning(true) setTimeout(() => { setCurrentStep(stepIndex) setTimeout(() => setIsTransitioning(false), 50) }, 300) } } const activeStep = vgnSteps[currentStep] if (!autoStart && !isModalOpen) { return (
VGN Preview
) } return ( <>
e.stopPropagation()}>
VGN {currentStep > 0 && ( <> {activeStep.region.topPct > 0 && (
)} {activeStep.region.leftPct > 0 && (
)} {activeStep.region.leftPct + activeStep.region.widthPct < 100 && (
)} {activeStep.region.topPct + activeStep.region.heightPct < 100 && (
)}
)}
{currentStep + 1}/{vgnSteps.length}

{activeStep.title}

{activeStep.description}

{vgnSteps.map((step, index) => (
handleStepClick(index)} title={step.title}>
{index + 1}
))}
) }