import { RaftTypeE } from "@robotical/webapp-types/dist-types/src/types/raft";
import ConnectButton from "./connect-button";
import DisconnectButton from "./disconnect-butotn";
import styles from "./styles.module.css";
import RAFT from "@robotical/webapp-types/dist-types/src/application/RAFTs/RAFT";

interface ConnectionProps {
    connectedCog: RAFT | null;
    setConnectedCog: (connectedCog: RAFT | null) => void;
    handleDisconnect: () => void;
    handleConnect: () => void;
}

export default function Connection({ connectedCog, setConnectedCog, handleDisconnect, handleConnect }: ConnectionProps) {
    return <div className={styles.connectionContainer}>
        {connectedCog ?
            <DisconnectButton onClickDisconnect={handleDisconnect} connectedRaft={connectedCog} robotType={RaftTypeE.COG} /> :
            <ConnectButton raftType={RaftTypeE.COG} onConnect={handleConnect} />
        }
    </div>;
}