import React, { useEffect } from 'react';
import { useParams, useSearchParams, useNavigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';
import RemoteDesktopPanel from '../components/common/RemoteDesktopPanel';

export default function RdpPage() {
    const { agentId } = useParams();
    const [searchParams] = useSearchParams();
    const { isAuthenticated } = useAuth();
    const navigate = useNavigate();

    useEffect(() => {
        if (!isAuthenticated) navigate('/login', { replace: true });
    }, [isAuthenticated]);

    if (!isAuthenticated) return null;

    return (
        <div style={{ height: '100vh', width: '100vw', background: '#0d1117', overflow: 'hidden' }}>
            <RemoteDesktopPanel
                agentId={parseInt(agentId)}
                agentHostname=""
                autoConnect={true}
                fullscreen={true}
            />
        </div>
    );
}
