import React, { useState, useEffect } from 'react' import { connect } from 'react-redux' import { getChart, getUserTriggers, getUserNotifications, getUserTransactions } from '../../stores/exchange/duck/operations' import { useInterval } from '../useInterval' import ExchangeTriggerAdd from './exchangeTriggerAdd' import ExchangePrognosis from './exchangePrognosis' import ExchangeNotifications from './exchangeNotifications' import '../../styles/indexExchange.scss' const IndexExchange = ({ user, exchange, getChart, getUserTriggers, getUserNotifications, getUserTransactions }) => { let fifteenMinuts = 1500000 useInterval( () => { getChart() }, fifteenMinuts ) const [candleInfo, setCandleInfo] = useState( { Open: 0, Close: 0, Min: 0, Max: 0, Vol: 0 } ) const [mousePosition, setMousePosition] = useState( { x: 0, y: 0 } ) const [triggerValue, setTriggerValue] = useState(0) const colorGreen = { background: 'green'//'rgba(0,93,0,1)', } const colorRed = { background: 'red'//'rgba(136,15,15,1)', } const getCandleInformation = (candle) => { setCandleInfo( { Open: candle.Open, Close: candle.Close, Min: candle.Min, Max: candle.Max, Vol: candle.Volume, Date: candle.Date } ) } let pixelScale = ( exchange.candles.graphMax - exchange.candles.graphMin ) / 590 let cursorValue = exchange.candles.graphMax - ( pixelScale * ( mousePosition.y - 175 ) ) const getMousePosition = (event) => { setMousePosition( { x: event.pageX, y: event.pageY } ) } return (
{ parseInt(cursorValue) } PLN
Open: { candleInfo.Open } PLN,
Close: { candleInfo.Close } PLN,
Max: { candleInfo.Max } PLN,
Min: { candleInfo.Min } PLN,
Volume: { candleInfo.Vol },
Date: { candleInfo.Date }