add Dative for users in exchange
parent
d03d8bb92d
commit
721d05a42c
|
|
@ -0,0 +1,36 @@
|
||||||
|
import React, { useState, useEffect } from 'react'
|
||||||
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
|
import { getChart, getUserTriggers, getUserNotifications, getUserTransactions } from '../../stores/exchange/duck/operations'
|
||||||
|
|
||||||
|
import '../../styles/indexExchange.scss'
|
||||||
|
|
||||||
|
const ExchangeTriggerAdd = ({
|
||||||
|
user,
|
||||||
|
exchange, getChart, getUserTriggers, getUserNotifications, getUserTransactions,
|
||||||
|
mousePosition }) => {
|
||||||
|
|
||||||
|
useEffect( () => { getUserTriggers(user) }, [] )
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='exchangeTriggerDativeY'
|
||||||
|
style={ { marginTop: mousePosition.y + 'px' } }>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
user: state.user,
|
||||||
|
exchange: state.exchange
|
||||||
|
})
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
getChart: exchange => dispatch( getChart(exchange) ),
|
||||||
|
getUserTriggers: exchange => dispatch( getUserTriggers(exchange) ),
|
||||||
|
getUserNotifications: exchange => dispatch( getUserNotifications(exchange) ),
|
||||||
|
getUserTransactions: exchange => dispatch( getUserTransactions(exchange) )
|
||||||
|
})
|
||||||
|
|
||||||
|
export default connect(mapStateToProps,mapDispatchToProps)(ExchangeTriggerAdd)
|
||||||
|
|
@ -1,24 +1,29 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
import { getChart, getTriggers, getNotifications, getTransactions } from '../../stores/exchange/duck/operations'
|
import { getChart, getUserTriggers, getUserNotifications, getUserTransactions } from '../../stores/exchange/duck/operations'
|
||||||
|
|
||||||
|
import ExchangeTriggerAdd from './exchangeTriggerAdd'
|
||||||
|
|
||||||
import '../../styles/indexExchange.scss'
|
import '../../styles/indexExchange.scss'
|
||||||
|
|
||||||
const IndexExchange = ({
|
const IndexExchange = ({
|
||||||
user,
|
user,
|
||||||
exchange, getChart, getTriggers, getNotifications, getTransactions }) => {
|
exchange, getChart, getUserTriggers, getUserNotifications, getUserTransactions }) => {
|
||||||
|
|
||||||
useEffect( () => { getChart() }, [] )
|
useEffect( () => { getChart() }, [] )
|
||||||
|
useEffect( () => { getUserTriggers() }, [] )
|
||||||
|
|
||||||
const [candleInfo, setCandleInfo] = useState( { Open: 0, Close: 0, Min: 0, Max: 0, Vol: 0 } )
|
const [candleInfo, setCandleInfo] = useState( { Open: 0, Close: 0, Min: 0, Max: 0, Vol: 0 } )
|
||||||
|
|
||||||
|
const [mousePosition, setMousePosition] = useState( { x: 0, y: 0 } )
|
||||||
|
|
||||||
const colorGreen = {
|
const colorGreen = {
|
||||||
background: 'green',
|
background: 'green'//'rgba(0,93,0,1)',
|
||||||
}
|
}
|
||||||
|
|
||||||
const colorRed = {
|
const colorRed = {
|
||||||
background: 'red',
|
background: 'red'//'rgba(136,15,15,1)',
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCandleInformation = (candle) => {
|
const getCandleInformation = (candle) => {
|
||||||
|
|
@ -33,28 +38,48 @@ const IndexExchange = ({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let pixelScale = ( exchange.candles.graphMax - exchange.candles.graphMin ) / 590
|
||||||
|
|
||||||
|
const getMousePosition = (event) => {
|
||||||
|
setMousePosition( { x: event.pageX, y: event.pageY } )
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='indexExchange'>
|
<div className='indexExchange'>
|
||||||
<div className={ user.id > -1 ? 'exchangeChartUser' : 'exchangeChartGuest' }>
|
<div className={ user.id > -1 ? 'exchangeChartUser' : 'exchangeChartGuest' }>
|
||||||
<div className='chart' style={ { width: exchange.candles.candlesCount * 15 + 'px' } }>
|
<div className='chart'
|
||||||
|
onMouseOver={ event => getMousePosition(event) }
|
||||||
|
style={ { width: exchange.candles.candlesCount * 15 + 'px' } }>
|
||||||
|
{ user.id > -1 ? (
|
||||||
|
<div>
|
||||||
|
<div className='exchangeTriggerDativeY'
|
||||||
|
style={ { transform: 'translateY(' + (mousePosition.y - 175) + 'px)' } }>
|
||||||
|
<p>{ ( exchange.candles.graphMax - ( pixelScale * ( mousePosition.y - 175 ) ) ) }</p>
|
||||||
|
</div>
|
||||||
|
<div className='exchangeTriggerDativeX'
|
||||||
|
style={ { transform: 'translateX(' + (mousePosition.x) + 'px)' } }>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div></div>
|
||||||
|
) }
|
||||||
{ exchange.candles.candles.map( (candle, key) => {
|
{ exchange.candles.candles.map( (candle, key) => {
|
||||||
|
|
||||||
const color = candle.Open > candle.Close ? colorRed.background : colorGreen.background
|
const color = candle.Open > candle.Close ? colorRed.background : colorGreen.background
|
||||||
|
|
||||||
let highValue = candle.Open > candle.Close ? candle.Open : candle.Close
|
let highValue = candle.Open > candle.Close ? candle.Open : candle.Close
|
||||||
let lowValue = candle.Open < candle.Close ? candle.Open : candle.Close
|
let lowValue = candle.Open < candle.Close ? candle.Open : candle.Close
|
||||||
let difference = highValue - lowValue
|
|
||||||
|
|
||||||
let chartScaleY = (exchange.candles.graphMax - candle.Max) / 8
|
let scaleProperties = 8
|
||||||
|
|
||||||
if ( difference > 0 && difference < 10 )
|
let chartScaleY = (exchange.candles.graphMax - candle.Max) / scaleProperties
|
||||||
difference *= 2
|
|
||||||
else if ( difference > 50 && difference < 100 )
|
let onePercentScaleY = 100 / chartScaleY
|
||||||
difference /= 2
|
let difference = (( highValue - lowValue ) / onePercentScaleY ) / scaleProperties
|
||||||
else if ( difference >= 100 && difference <= 200 )
|
|
||||||
difference /= 3
|
if ( parseInt(difference) === 0 )
|
||||||
else if ( difference > 200 )
|
difference = 1
|
||||||
difference = difference % 100
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -65,32 +90,22 @@ const IndexExchange = ({
|
||||||
<div className='sectionCandle'>
|
<div className='sectionCandle'>
|
||||||
<div
|
<div
|
||||||
className='candle'
|
className='candle'
|
||||||
style={ { paddingTop: chartScaleY + 'px' } }
|
style={ { paddingTop: chartScaleY + 'px' } }>
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
className='candleMaxValue'
|
className='candleMaxValue'
|
||||||
style={ { height: parseInt( (candle.Max - highValue ) / 2 ) + 'px',
|
style={ { height: parseInt( (candle.Max - highValue ) / scaleProperties ) + 'px', background: color }}>
|
||||||
background: color }
|
|
||||||
}>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className='candleHigh'
|
className='candleHigh'
|
||||||
style={
|
style={{ height: parseInt( difference ) + 'px', background: color }}>
|
||||||
{ height: parseInt( difference ) + 'px',
|
|
||||||
background: color }
|
|
||||||
}>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className='candleLow'
|
className='candleLow'
|
||||||
style={ { height: parseInt( difference ) + 'px',
|
style={{ height: parseInt( difference ) + 'px', background: color }}>
|
||||||
background: color }
|
|
||||||
}>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className='candleMinValue'
|
className='candleMinValue'
|
||||||
style={ { height: parseInt( ( lowValue - candle.Min ) / 2 ) + 'px',
|
style={ { height: parseInt( ( lowValue - candle.Min ) / scaleProperties ) + 'px', background: color }}>
|
||||||
background: color }
|
|
||||||
}>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -108,11 +123,13 @@ const IndexExchange = ({
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={ user.id > -1 ? 'exchangeInterface' : 'emptySpaceExchange' }>
|
<div className={ user.id > -1 ? 'exchangeInterface' : 'exchangeEmptySpace' }>
|
||||||
<div>
|
<div className='candleInformation'>
|
||||||
<p>Open: { candleInfo.Open }, Close: { candleInfo.Close }</p>
|
<p>Open: { candleInfo.Open },</p>
|
||||||
<p>Max: { candleInfo.Max }, Min: { candleInfo.Min }</p>
|
<p>Close: { candleInfo.Close },</p>
|
||||||
<p>Volume: { candleInfo.Vol }</p>
|
<p>Max: { candleInfo.Max },</p>
|
||||||
|
<p>Min: { candleInfo.Min },</p>
|
||||||
|
<p>Volume: { candleInfo.Vol },</p>
|
||||||
<p>Date: { candleInfo.Date }</p>
|
<p>Date: { candleInfo.Date }</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -120,6 +137,7 @@ const IndexExchange = ({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
user: state.user,
|
user: state.user,
|
||||||
exchange: state.exchange
|
exchange: state.exchange
|
||||||
|
|
@ -127,9 +145,9 @@ const mapStateToProps = state => ({
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
getChart: exchange => dispatch( getChart(exchange) ),
|
getChart: exchange => dispatch( getChart(exchange) ),
|
||||||
getTriggers: exchange => dispatch( getTriggers(exchange) ),
|
getUserTriggers: exchange => dispatch( getUserTriggers(exchange) ),
|
||||||
getNotifications: exchange => dispatch( getNotifications(exchange) ),
|
getUserNotifications: exchange => dispatch( getUserNotifications(exchange) ),
|
||||||
getTransactions: exchange => dispatch( getTransactions(exchange) )
|
getUserTransactions: exchange => dispatch( getUserTransactions(exchange) )
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(mapStateToProps,mapDispatchToProps)(IndexExchange)
|
export default connect(mapStateToProps,mapDispatchToProps)(IndexExchange)
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export const getChart = () =>
|
||||||
dispatch(actions.setChart(chart))
|
dispatch(actions.setChart(chart))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getGetUserTriggers = () =>
|
export const getUserTriggers = () =>
|
||||||
async (dispatch) => {
|
async (dispatch) => {
|
||||||
const triggers = await fetchGetUserTriggers()
|
const triggers = await fetchGetUserTriggers()
|
||||||
dispatch(actions.setUserTriggers(triggers))
|
dispatch(actions.setUserTriggers(triggers))
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin scrollStyle {
|
@mixin scrollStyle {
|
||||||
margin-top: 5px;
|
width: 10px;
|
||||||
margin-bottom: 5px;
|
height: 10px;
|
||||||
border: 0px;
|
background-color: rgba(22,28,29,0.5);
|
||||||
border-radius: 10px;
|
|
||||||
font-size: 12pt;
|
|
||||||
text-align: center;
|
|
||||||
color: rgba(111,108,106,1);
|
|
||||||
background-color: rgba(22,28,29,0.6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin inputStyle {
|
@mixin inputStyle {
|
||||||
|
|
@ -59,6 +54,10 @@
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin backgroundColorOnly {
|
||||||
|
background-color: rgba(22,28,29,0.4);
|
||||||
|
}
|
||||||
|
|
||||||
@mixin backgroundDivMenubarStyle {
|
@mixin backgroundDivMenubarStyle {
|
||||||
background-color: rgba(22,28,29,0.2);
|
background-color: rgba(22,28,29,0.2);
|
||||||
border-bottom: 1px solid;
|
border-bottom: 1px solid;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
|
||||||
padding-top: 20vh;
|
padding-top: 175px;
|
||||||
|
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 600px;
|
height: 600px;
|
||||||
overflow-y: hidden;
|
overflow: hidden;
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
|
|
||||||
.chart {
|
.chart {
|
||||||
|
|
@ -34,6 +34,11 @@
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
float: left;
|
float: left;
|
||||||
|
|
||||||
|
opacity: 0.6;
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.sectionCandle {
|
.sectionCandle {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 400px;
|
height: 400px;
|
||||||
|
|
@ -73,8 +78,7 @@
|
||||||
.volumen {
|
.volumen {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
background: gray;
|
background: rgba(0,0,0,0.3);
|
||||||
opacity: 0.8;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,3 +94,49 @@
|
||||||
.exchangeChartUser {
|
.exchangeChartUser {
|
||||||
@include exchangeChart
|
@include exchangeChart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin exchangeInterface {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
background: rgba(0,0,0,0.2);
|
||||||
|
|
||||||
|
.candleInformation {
|
||||||
|
width: 1500px;
|
||||||
|
height: 20px;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
|
||||||
|
p {
|
||||||
|
width: 250px;
|
||||||
|
text-align: center;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.exchangeEmptySpace {
|
||||||
|
@include exchangeInterface
|
||||||
|
}
|
||||||
|
.exchangeInterface {
|
||||||
|
@include exchangeInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
.exchangeTriggerDativeY {
|
||||||
|
z-index: -1;
|
||||||
|
position: fixed;
|
||||||
|
width: 100vw;
|
||||||
|
height: 1px;
|
||||||
|
background-color: rgba(117,82,29,1);
|
||||||
|
transform: margin 700ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.exchangeTriggerDativeX {
|
||||||
|
z-index: -1;
|
||||||
|
position: fixed;
|
||||||
|
width: 1px;
|
||||||
|
height: 590px;
|
||||||
|
background-color: rgba(117,82,29,1);
|
||||||
|
transform: margin 700ms;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue