import React from "react";
import ReactDOM from "react-dom";
import "bootstrap/dist/css/bootstrap.css";
import App from "./components/App";
import io from "socket.io-client";

export const socket = io();


export type PositionState = {
    id: number,
    state: string,
    base_price: number,
    amount: number,
    symbol: string,
    profit_loss: number,
    profit_loss_percentage: number
}

export type FirstConnectMessage = {
    ticks: Array<number>,
    prices: Array<number>,
    positions: Array<PositionState>
}

export type NewEventMessage = {
    tick: number,
    kind: string,
}

export type NewTickMessage = {
    tick: number,
    price: number,
    positions: Array<PositionState>
}

export type PositionCloseMessage = {
    message_name: string,
    position_id: number,
}

socket.on("connect", function () {
    console.log("Connected!")
})

ReactDOM.render(<App/>, document.getElementById("root"));
