-
- {buildPercentageView(value, 'cashIn')}
-
-
- {buildPercentageView(100 - value, 'cashOut')}
-
+
+
+ {buildPercentageView(value, 'cashIn')}
- >
+
+ {buildPercentageView(100 - value, 'cashOut')}
+
+
)
}
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefLineChart.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefLineChart.js
index bf0f4d48..29d92d4f 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefLineChart.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefLineChart.js
@@ -1,80 +1,66 @@
import * as d3 from 'd3'
import * as R from 'ramda'
-import React, { useEffect, useRef, useCallback, useState } from 'react'
+import React, { useEffect, useRef, useCallback } from 'react'
import { backgroundColor, zircon, primaryColor } from 'src/styling/variables'
+const transactionProfit = tx => {
+ const cashInFee = tx.cashInFee ? Number.parseFloat(tx.cashInFee) : 0
+ const commission =
+ Number.parseFloat(tx.commissionPercentage) * Number.parseFloat(tx.fiat)
+ return commission + cashInFee
+}
+
+const mockPoint = tx => {
+ const date = new Date(tx.created)
+ date.setHours(date.getHours() - 1)
+ return { created: date.toISOString(), profit: tx.profit }
+}
+
+// if we're viewing transactions for the past day, then we group by hour. If not, we group by day
+const formatDay = ({ created }) =>
+ new Date(created).toISOString().substring(0, 10)
+const formatHour = ({ created }) =>
+ new Date(created).toISOString().substring(0, 13)
+
+const reducer = (acc, tx) => {
+ const currentProfit = acc.profit || 0
+ return { ...tx, profit: currentProfit + transactionProfit(tx) }
+}
+
const RefLineChart = ({ data: realData, timeFrame }) => {
const svgRef = useRef()
- // this variable will flip to true if there's no data points or the profit is zero
- // this will force the line graph to touch the x axis instead of centering,
- // centering is bad because it gives the impression that there could be negative values
- // so, if this is true the y domain should be [0, 0.1]
- const [zeroProfit, setZeroProfit] = useState(false)
-
const drawGraph = useCallback(() => {
const svg = d3.select(svgRef.current)
const margin = { top: 0, right: 0, bottom: 0, left: 0 }
const width = 336 - margin.left - margin.right
const height = 128 - margin.top - margin.bottom
- const transactionProfit = tx => {
- let cashInFee = 0
- if (tx.cashInFee) {
- cashInFee = Number.parseFloat(tx.cashInFee)
- }
- const commission =
- Number.parseFloat(tx.commissionPercentage) * Number.parseFloat(tx.fiat)
- return commission + cashInFee
- }
-
const massageData = () => {
- const methods = {
- day: function(obj) {
- return new Date(obj.created).toISOString().substring(0, 10)
- },
- hour: function(obj) {
- return new Date(obj.created).toISOString().substring(0, 13)
- }
- }
+ // if we're viewing transactions for the past day, then we group by hour. If not, we group by day
+ const method = timeFrame === 'Day' ? formatHour : formatDay
- const method = timeFrame === 'Day' ? 'hour' : 'day'
- const f = methods[method]
- const groupedTx = R.values(R.groupBy(f)(realData))
- let aggregatedTX = groupedTx.map(list => {
- const temp = { ...list[0], profit: transactionProfit(list[0]) }
- if (list.length > 1) {
- for (let i = 1; i < list.length; i++) {
- temp.profit += transactionProfit(list[i])
- }
- }
- return temp
- })
-
- // if no point exists, then create a (0,0) point
+ const aggregatedTX = R.values(R.reduceBy(reducer, [], method, realData))
+ // if no point exists, then return 2 points at y = 0
if (aggregatedTX.length === 0) {
- setZeroProfit(true)
- aggregatedTX = [{ created: new Date().toISOString(), profit: 0 }]
- } else {
- setZeroProfit(false)
+ const mockPoint1 = { created: new Date().toISOString(), profit: 0 }
+ const mockPoint2 = mockPoint(mockPoint1)
+ return [[mockPoint1, mockPoint2], true]
}
- // create point on the left if only one point exists, otherwise line won't be drawn
+ // if only one point exists, create point on the left - otherwise the line won't be drawn
if (aggregatedTX.length === 1) {
- const temp = { ...aggregatedTX[0] }
- const date = new Date(temp.created)
- date.setHours(date.getHours() - 1)
- temp.created = date.toISOString()
- aggregatedTX = [...aggregatedTX, temp]
+ return [R.append(mockPoint(aggregatedTX[0]), aggregatedTX), false]
}
- return aggregatedTX
+ // the boolean value is for zeroProfit. It makes the line render at y = 0 instead of y = 50% of container height
+ return [aggregatedTX, false]
}
/* Important step to make the graph look good!
- This function groups transactions by either day or hour depending on the time grame
+ This function groups transactions by either day or hour depending on the time frame
This makes the line look smooth and not all wonky when there are many transactions in a given time
*/
- const data = massageData()
+ const [data, zeroProfit] = massageData()
// sets width of the graph
svg.attr('width', width)
@@ -162,7 +148,7 @@ const RefLineChart = ({ data: realData, timeFrame }) => {
.attr('stroke-width', '2')
.attr('stroke-linejoin', 'round')
.attr('stroke', primaryColor)
- }, [realData, timeFrame, zeroProfit])
+ }, [realData, timeFrame])
useEffect(() => {
// first we clear old chart DOM elements on component update
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefScatterplot.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefScatterplot.js
index e63bdc32..4d7da250 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefScatterplot.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/RefScatterplot.js
@@ -18,21 +18,17 @@ const RefScatterplot = ({ data: realData, timeFrame }) => {
// finds maximum value for the Y axis. Minimum value is 100. If value is multiple of 1000, add 100
// (this is because the Y axis looks best with multiples of 100)
const findMaxY = () => {
- if (realData.length === 0) {
- return 100
- }
- let maxY = d3.max(realData, t => parseFloat(t.fiat))
- maxY = 100 * Math.ceil(maxY / 100)
- if (maxY < 100) {
- return 100
- } else if (maxY % 1000 === 0) {
- return maxY + 100
- }
+ if (realData.length === 0) return 100
+ const maxvalueTx =
+ 100 * Math.ceil(d3.max(realData, t => parseFloat(t.fiat)) / 100)
+ const maxY = Math.max(100, maxvalueTx)
+ if (maxY % 1000 === 0) return maxY + 100
return maxY
}
// changes values of arguments in some d3 function calls to make the graph labels look good according to the selected time frame
const findXAxisSettings = () => {
+ // case 'Day' or default
const res = {
nice: null,
ticks: 4,
@@ -41,11 +37,8 @@ const RefScatterplot = ({ data: realData, timeFrame }) => {
timeRange: [50, 500]
}
switch (timeFrame) {
- case 'Day':
- return res
case 'Week':
return {
- ...res,
nice: 7,
ticks: 7,
subtractDays: 7,
@@ -54,7 +47,6 @@ const RefScatterplot = ({ data: realData, timeFrame }) => {
}
case 'Month':
return {
- ...res,
nice: 6,
ticks: 6,
subtractDays: 30,
@@ -133,10 +125,8 @@ const RefScatterplot = ({ data: realData, timeFrame }) => {
.ticks(xAxisSettings.ticks)
.tickSize(0)
.tickFormat(d3.timeFormat(xAxisSettings.timeFormat))
- // .tickFormat(d3.timeFormat('%H:%M'))
)
.selectAll('text')
- // .attr('dx', '4em')
.attr('dy', '1.5em')
// this is for the x axis line. It is the same color as the horizontal grid lines
g.append('g')
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/Scatterplot.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/Scatterplot.js
deleted file mode 100644
index ef08a169..00000000
--- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Graphs/Scatterplot.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/*eslint-disable*/
-import { scaleLinear, scaleTime, max, axisLeft, axisBottom, select } from 'd3'
-import React, { useMemo } from 'react'
-import moment from 'moment'
-
-const data = [
- [0, '2020-11-08T18:00:05.664Z'],
- [40.01301, '2020-11-09T11:17:05.664Z']
-]
-
-const marginTop = 10
-const marginRight = 30
-const marginBottom = 30
-const marginLeft = 60
-const width = 510 - marginLeft - marginRight
-const height = 141 - marginTop - marginBottom
-
-const Scatterplot = ({ data: realData }) => {
- const x = scaleTime()
- .domain([
- moment()
- .add(-1, 'day')
- .valueOf(),
- moment().valueOf()
- ])
- .range([0, width])
- .nice()
-
- const y = scaleLinear()
- .domain([0, 1000])
- .range([height, 0])
- .nice()
-
- // viewBox="0 0 540 141"
- return (
- <>
-
- >
- )
-}
-
-const XAxis = ({
- range = [10, 500],
- transform,
- scale: xScale,
- numTicks = 7
-}) => {
- const ticks = useMemo(() => {
- return xScale.ticks(numTicks).map(value => ({
- value,
- xOffset: xScale(value)
- }))
- }, [range.join('-')])
-
- return (
-
- {ticks.map(({ value, xOffset }) => (
-
-
- {value.getHours()}
-
-
- ))}
-
- )
-}
-
-const YAxis = ({
- range = [10, 500],
- transform,
- scale: xScale,
- numTicks = 7
-}) => {
- const ticks = useMemo(() => {
- return xScale.ticks(numTicks).map(value => ({
- value,
- xOffset: xScale(value)
- }))
- }, [range.join('-')])
-
- return (
-
- {ticks.map(({ value, xOffset }) => (
-
-
- {value}
-
-
- ))}
-
- )
-}
-
-const RenderCircles = ({ data, scale }) => {
- let renderCircles = data.map((item, idx) => {
- return (
-
- )
- })
- return
{renderCircles}
-}
-
-export default Scatterplot
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js
index 216c98fe..04c9bd7a 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js
@@ -1,21 +1,20 @@
-// import Button from '@material-ui/core/Button'
import { makeStyles } from '@material-ui/core/styles'
import classnames from 'classnames'
+import * as R from 'ramda'
import React, { useState } from 'react'
import { H4 } from 'src/components/typography'
import styles from './SystemPerformance.styles'
+
const useStyles = makeStyles(styles)
+const ranges = ['Month', 'Week', 'Day']
const Nav = ({ handleSetRange }) => {
const classes = useStyles()
const [clickedItem, setClickedItem] = useState('Day')
- const isSelected = innerText => {
- return innerText === clickedItem
- }
-
+ const isSelected = R.equals(clickedItem)
const handleClick = range => {
setClickedItem(range)
handleSetRange(range)
@@ -26,34 +25,21 @@ const Nav = ({ handleSetRange }) => {
{'System performance'}
-
-
handleClick(e.target.innerText)}
- className={
- isSelected('Month')
- ? classnames(classes.newHighlightedLabel, classes.navButton)
- : classnames(classes.label, classes.navButton)
- }>
- Month
-
-
handleClick(e.target.innerText)}
- className={
- isSelected('Week')
- ? classnames(classes.newHighlightedLabel, classes.navButton)
- : classnames(classes.label, classes.navButton)
- }>
- Week
-
-
handleClick(e.target.innerText)}>
- Day
-
+
+ {ranges.map((it, idx) => {
+ return (
+
handleClick(e.target.innerText)}
+ className={
+ isSelected(it)
+ ? classnames(classes.newHighlightedLabel, classes.navButton)
+ : classnames(classes.label, classes.navButton)
+ }>
+ {it}
+
+ )
+ })}
)
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js
index 08ddf06a..fd23dce7 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js
@@ -1,10 +1,11 @@
import { useQuery } from '@apollo/react-hooks'
import Grid from '@material-ui/core/Grid'
import { makeStyles } from '@material-ui/core/styles'
+import BigNumber from 'bignumber.js'
import gql from 'graphql-tag'
import moment from 'moment'
import * as R from 'ramda'
-import React, { useState, useEffect } from 'react'
+import React, { useState } from 'react'
import { Label2 } from 'src/components/typography/index'
import { ReactComponent as TriangleDown } from 'src/styling/icons/arrow/triangle_down.svg'
@@ -18,18 +19,31 @@ import InfoWithLabel from './InfoWithLabel'
import Nav from './Nav'
import styles from './SystemPerformance.styles'
-const isNotProp = R.curry(R.compose(R.isNil, R.prop))
+BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_HALF_UP })
+
const getFiats = R.map(R.prop('fiat'))
-const getProps = propName => R.map(R.prop(propName))
const useStyles = makeStyles(styles)
+const mapToFee = R.map(R.prop('cashInFee'))
+
const getDateSecondsAgo = (seconds = 0, startDate = null) => {
- if (startDate) {
- return moment(startDate).subtract(seconds, 'second')
- }
- return moment().subtract(seconds, 'second')
+ const date = startDate ? moment(startDate) : moment()
+ return date.subtract(seconds, 'second')
}
-// const now = moment()
+const ranges = {
+ Day: {
+ left: getDateSecondsAgo(2 * 24 * 3600, moment()),
+ right: getDateSecondsAgo(24 * 3600, moment())
+ },
+ Week: {
+ left: getDateSecondsAgo(14 * 24 * 3600, moment()),
+ right: getDateSecondsAgo(7 * 24 * 3600, moment())
+ },
+ Month: {
+ left: getDateSecondsAgo(60 * 24 * 3600, moment()),
+ right: getDateSecondsAgo(30 * 24 * 3600, moment())
+ }
+}
const GET_DATA = gql`
query getData {
@@ -42,7 +56,7 @@ const GET_DATA = gql`
txClass
error
}
- btcRates {
+ fiatRates {
code
name
rate
@@ -51,134 +65,72 @@ const GET_DATA = gql`
}
`
+const reducer = (acc, it) =>
+ (acc +=
+ Number.parseFloat(it.commissionPercentage) * Number.parseFloat(it.fiat))
+
const SystemPerformance = () => {
const classes = useStyles()
-
const [selectedRange, setSelectedRange] = useState('Day')
- const [transactionsToShow, setTransactionsToShow] = useState([])
- const [transactionsLastTimePeriod, setTransactionsLastTimePeriod] = useState(
- []
- )
-
const { data, loading } = useQuery(GET_DATA)
-
const fiatLocale = fromNamespace('locale')(data?.config).fiatCurrency
- useEffect(() => {
- const isInRange = (getLastTimePeriod = false) => t => {
- const now = moment()
- switch (selectedRange) {
- case 'Day':
- if (getLastTimePeriod) {
- return (
- t.error === null &&
- moment(t.created).isBetween(
- getDateSecondsAgo(2 * 24 * 3600, now),
- getDateSecondsAgo(24 * 3600, now)
- )
- )
- }
- return (
- t.error === null &&
- moment(t.created).isBetween(getDateSecondsAgo(24 * 3600, now), now)
- )
- case 'Week':
- if (getLastTimePeriod) {
- return (
- t.error === null &&
- moment(t.created).isBetween(
- getDateSecondsAgo(14 * 24 * 3600, now),
- getDateSecondsAgo(7 * 24 * 3600, now)
- )
- )
- }
- return (
- t.error === null &&
- moment(t.created).isBetween(
- getDateSecondsAgo(7 * 24 * 3600, now),
- now
- )
- )
- case 'Month':
- if (getLastTimePeriod) {
- return (
- t.error === null &&
- moment(t.created).isBetween(
- getDateSecondsAgo(60 * 24 * 3600, now),
- getDateSecondsAgo(30 * 24 * 3600, now)
- )
- )
- }
- return (
- t.error === null &&
- moment(t.created).isBetween(
- getDateSecondsAgo(30 * 24 * 3600, now),
- now
- )
- )
- default:
- return t.error === null && true
- }
+ const isInRangeAndNoError = getLastTimePeriod => t => {
+ if (t.error !== null) return false
+ if (!getLastTimePeriod) {
+ return (
+ t.error === null &&
+ moment(t.created).isBetween(ranges[selectedRange].right, moment())
+ )
}
-
- const convertFiatToLocale = item => {
- if (item.fiatCode === fiatLocale) return item
- const itemRate = R.find(R.propEq('code', item.fiatCode))(data.btcRates)
- const localeRate = R.find(R.propEq('code', fiatLocale))(data.btcRates)
- const multiplier = localeRate.rate / itemRate.rate
- return { ...item, fiat: parseFloat(item.fiat) * multiplier }
- }
-
- setTransactionsToShow(
- R.map(convertFiatToLocale)(
- R.filter(isInRange(false), data?.transactions ?? [])
+ return (
+ t.error === null &&
+ moment(t.created).isBetween(
+ ranges[selectedRange].left,
+ ranges[selectedRange].right
)
)
- setTransactionsLastTimePeriod(
- R.map(convertFiatToLocale)(
- R.filter(isInRange(true), data?.transactions ?? [])
- )
- )
- }, [data, fiatLocale, selectedRange])
-
- const handleSetRange = range => {
- setSelectedRange(range)
}
+ const convertFiatToLocale = item => {
+ if (item.fiatCode === fiatLocale) return item
+ const itemRate = R.find(R.propEq('code', item.fiatCode))(data.fiatRates)
+ const localeRate = R.find(R.propEq('code', fiatLocale))(data.fiatRates)
+ const multiplier = localeRate.rate / itemRate.rate
+ return { ...item, fiat: parseFloat(item.fiat) * multiplier }
+ }
+
+ const transactionsToShow = R.map(convertFiatToLocale)(
+ R.filter(isInRangeAndNoError(false), data?.transactions ?? [])
+ )
+ const transactionsLastTimePeriod = R.map(convertFiatToLocale)(
+ R.filter(isInRangeAndNoError(true), data?.transactions ?? [])
+ )
+
const getNumTransactions = () => {
- return R.length(R.filter(isNotProp('error'), transactionsToShow))
+ return R.length(transactionsToShow)
}
- const getFiatVolume = () => {
- // for explanation check https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
- return +(
- Math.round(
- R.sum(getFiats(R.filter(isNotProp('error'), transactionsToShow))) +
- 'e+2'
- ) + 'e-2'
- )
- }
+ const getFiatVolume = () =>
+ new BigNumber(R.sum(getFiats(transactionsToShow)))
+ .decimalPlaces(2)
+ .toNumber()
- const getProfit = (transactions = transactionsToShow) => {
- const cashInFees = R.sum(
- getProps('cashInFee')(R.filter(isNotProp('error'), transactions))
- )
- let commissionFees = 0
- transactions.forEach(t => {
- if (t.error === null) {
- commissionFees +=
- Number.parseFloat(t.commissionPercentage) * Number.parseFloat(t.fiat)
- }
- })
- return +(Math.round(commissionFees + cashInFees + 'e+2') + 'e-2')
+ const getProfit = transactions => {
+ const cashInFees = R.sum(mapToFee(transactions))
+ const commissionFees = R.reduce(reducer, 0, transactions)
+
+ return new BigNumber(commissionFees + cashInFees)
+ .decimalPlaces(2)
+ .toNumber()
}
const getPercentChange = () => {
const thisTimePeriodProfit = getProfit(transactionsToShow)
const previousTimePeriodProfit = getProfit(transactionsLastTimePeriod)
- if (previousTimePeriodProfit === 0) {
- return 100
- }
+
+ if (previousTimePeriodProfit === 0) return 100
+
return Math.round(
(100 * (thisTimePeriodProfit - previousTimePeriodProfit)) /
Math.abs(previousTimePeriodProfit)
@@ -186,36 +138,17 @@ const SystemPerformance = () => {
}
const getDirectionPercent = () => {
- const directions = {
- cashIn: 0,
- cashOut: 0,
- length: 0
+ const [cashIn, cashOut] = R.partition(R.propEq('txClass', 'cashIn'))(
+ transactionsToShow
+ )
+ const totalLength = cashIn.length + cashOut.length
+ if (totalLength === 0) {
+ return { cashIn: 0, cashOut: 0 }
}
- transactionsToShow.forEach(t => {
- if (t.error === null) {
- switch (t.txClass) {
- case 'cashIn':
- directions.cashIn += 1
- directions.length += 1
- break
- case 'cashOut':
- directions.cashOut += 1
- directions.length += 1
- break
- default:
- break
- }
- }
- })
+
return {
- cashIn:
- directions.length > 0
- ? Math.round((directions.cashIn / directions.length) * 100)
- : 0,
- cashOut:
- directions.length > 0
- ? Math.round((directions.cashOut / directions.length) * 100)
- : 0
+ cashIn: Math.round((cashIn.length / totalLength) * 100),
+ cashOut: Math.round((cashOut.length / totalLength) * 100)
}
}
@@ -223,7 +156,7 @@ const SystemPerformance = () => {
return (
<>
-
+
{!loading && (
<>
@@ -241,7 +174,7 @@ const SystemPerformance = () => {
{/* todo new customers */}
-
+
Transactions
{
/>
-
+
Profit from commissions
-
+
- {`${getProfit()} ${data?.config.locale_fiatCurrency}`}
+ {`${getProfit(transactionsToShow)} ${
+ data?.config.locale_fiatCurrency
+ }`}
{percentChange <= 0 ? (
-
+
) : (
-
+
)}{' '}
{`${percentChange}%`}
@@ -281,7 +210,10 @@ const SystemPerformance = () => {
Direction
-
+
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.styles.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.styles.js
index a916e8dc..8ceb429c 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.styles.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.styles.js
@@ -5,8 +5,8 @@ import {
fontSize3,
fontSecondary,
fontColor,
- secondaryColorDarker,
- linkSecondaryColor
+ spring4,
+ tomato
} from 'src/styling/variables'
const styles = {
@@ -59,6 +59,9 @@ const styles = {
navButton: {
marginLeft: 24
},
+ navContainer: {
+ display: 'flex'
+ },
profitLabel: {
fontSize: fontSize3,
fontFamily: fontSecondary,
@@ -69,13 +72,24 @@ const styles = {
fontSize: fontSize3,
fontFamily: fontSecondary,
fontWeight: 700,
- color: secondaryColorDarker
+ color: spring4,
+ height: 10
},
percentDown: {
fontSize: fontSize3,
fontFamily: fontSecondary,
fontWeight: 700,
- color: linkSecondaryColor
+ color: tomato,
+ height: 13
+ },
+ profitContainer: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ margin: '0 26px -30px 16px',
+ position: 'relative'
+ },
+ gridContainer: {
+ marginTop: 30
}
}
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.js b/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.js
index 61e2c89d..df375db7 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.js
@@ -5,6 +5,7 @@ import TableCell from '@material-ui/core/TableCell'
import TableContainer from '@material-ui/core/TableContainer'
import TableHead from '@material-ui/core/TableHead'
import TableRow from '@material-ui/core/TableRow'
+import classnames from 'classnames'
import React from 'react'
import { useHistory } from 'react-router-dom'
@@ -57,73 +58,70 @@ const MachinesTable = ({ machines, numToRender }) => {
}
return (
- <>
-
-
-
-
-
-
- Machines
-
-
-
-
- Status
-
-
- {/*
+
+
+
+
+
+
+ Machines
+
+
+
+
+ Status
+
+
+ {/*
*/}
-
-
-
- 1
-
-
-
-
-
- 2
-
-
-
-
-
- {machines.map((machine, idx) => {
- if (idx < numToRender) {
- return (
- redirect(machine.name)}
- style={{ cursor: 'pointer' }}
- key={machine.deviceId + idx}
- className={classes.row}>
-
- {machine.name}
-
-
-
-
- {/*
+
+
+
+ 1
+
+
+
+
+
+ 2
+
+
+
+
+
+ {machines.map((machine, idx) => {
+ if (idx < numToRender) {
+ return (
+ redirect(machine.name)}
+ className={classnames(classes.row, classes.clickableRow)}
+ key={machine.deviceId + idx}>
+
+ {machine.name}
+
+
+
+
+ {/*
{makePercentageText(machine.cashbox)}
*/}
-
- {makePercentageText(machine.cassette1)}
-
-
- {makePercentageText(machine.cassette2)}
-
-
- )
- }
- return null
- })}
-
-
-
- >
+
+ {makePercentageText(machine.cassette1)}
+
+
+ {makePercentageText(machine.cassette2)}
+
+
+ )
+ }
+ return null
+ })}
+
+
+
)
}
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.styles.js b/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.styles.js
index 3c2060a6..5e90173d 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.styles.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemStatus/MachinesTable.styles.js
@@ -6,6 +6,10 @@ import {
} from 'src/styling/variables'
const styles = {
+ container: {
+ display: 'flex',
+ justifyContent: 'space-between'
+ },
label: {
margin: 0,
color: offColor
@@ -14,6 +18,9 @@ const styles = {
backgroundColor: backgroundColor,
borderBottom: 'none'
},
+ clickableRow: {
+ cursor: 'pointer'
+ },
header: {
display: 'flex',
alignItems: 'center',
@@ -32,11 +39,21 @@ const styles = {
backgroundColor: 'transparent'
}
},
+ buttonLabel: {
+ textAlign: 'center',
+ marginBottom: 0
+ },
+ upperButtonLabel: {
+ textAlign: 'center',
+ marginBottom: 0,
+ marginTop: 0
+ },
statusHeader: {
marginLeft: 2
},
- /* table: {
- maxHeight: 440,
+ /* // temporary class, until alerts are enabled. Delete this table class and uncomment the other one
+ table: {
+ height: 463,
'&::-webkit-scrollbar': {
width: 7
},
@@ -45,10 +62,8 @@ const styles = {
borderRadius: 5
}
}, */
- // temporary, when notifications are enabled delete this one and decomment above
table: {
- maxHeight: 465,
- minHeight: 465,
+ maxHeight: 440,
'&::-webkit-scrollbar': {
width: 7
},
@@ -62,6 +77,15 @@ const styles = {
},
h4: {
marginTop: 0
+ },
+ tl2: {
+ display: 'inline'
+ },
+ label1: {
+ display: 'inline'
+ },
+ machinesTableContainer: {
+ marginTop: 23
}
}
diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemStatus/SystemStatus.js b/new-lamassu-admin/src/pages/Dashboard/SystemStatus/SystemStatus.js
index 27a9e82c..189c0902 100644
--- a/new-lamassu-admin/src/pages/Dashboard/SystemStatus/SystemStatus.js
+++ b/new-lamassu-admin/src/pages/Dashboard/SystemStatus/SystemStatus.js
@@ -1,10 +1,11 @@
import { useQuery } from '@apollo/react-hooks'
-// import Button from '@material-ui/core/Button'
+import Button from '@material-ui/core/Button'
import Grid from '@material-ui/core/Grid'
import { makeStyles } from '@material-ui/core/styles'
import gql from 'graphql-tag'
-import React, { useState, useEffect } from 'react'
+import React from 'react'
+import { cardState as cardState_ } from 'src/components/CollapsibleCard'
// import ActionButton from 'src/components/buttons/ActionButton'
import { H4, TL2, Label1 } from 'src/components/typography'
@@ -14,7 +15,7 @@ import styles from './MachinesTable.styles'
const useStyles = makeStyles(styles)
// number of machines in the table to render on page load
-// const NUM_TO_RENDER = 3
+const NUM_TO_RENDER = 3
const GET_DATA = gql`
query getData {
@@ -38,97 +39,56 @@ const GET_DATA = gql`
}
`
-const parseUptime = time => {
+/* const parseUptime = time => {
if (time < 60) return `${time}s`
if (time < 3600) return `${Math.floor(time / 60)}m`
if (time < 86400) return `${Math.floor(time / 60 / 60)}h`
return `${Math.floor(time / 60 / 60 / 24)}d`
-}
+} */
-const SystemStatus = ({ cardState, setRightSideState }) => {
+const SystemStatus = ({ onReset, onExpand, size }) => {
const classes = useStyles()
const { data, loading } = useQuery(GET_DATA)
- const [showAllItems, setShowAllItems] = useState(false)
- // const [showExpandButton, setShowExpandButton] = useState(false)
- // const [numToRender, setNumToRender] = useState(NUM_TO_RENDER)
- useEffect(() => {
- /* if (showAllItems) {
- setShowExpandButton(false)
- setNumToRender(data?.machines.length)
- } else if (data && data?.machines.length > numToRender) {
- setShowExpandButton(true)
- } */
- if (cardState.cardSize === 'small' || cardState.cardSize === 'default') {
- setShowAllItems(false)
- // setNumToRender(NUM_TO_RENDER)
- }
- }, [cardState.cardSize, data, /* numToRender, */ showAllItems])
+ const showAllItems = size === cardState_.EXPANDED
- /* const reset = () => {
- setShowAllItems(false)
- setNumToRender(NUM_TO_RENDER)
- setRightSideState({
- systemStatus: { cardSize: 'default', buttonName: 'Show less' },
- alerts: { cardSize: 'default', buttonName: 'Show less' }
- })
- }
-
- const showAllClick = () => {
- setShowExpandButton(false)
- setShowAllItems(true)
- setRightSideState({
- systemStatus: { cardSize: 'big', buttonName: 'Show less' },
- alerts: { cardSize: 'small', buttonName: 'Show alerts' }
- })
- } */
-
- // placeholder data
- if (data) {
- data.uptime = [{ time: 1854125, state: 'RUNNING' }]
- }
-
- const uptime = data?.uptime ?? [{}]
+ // const uptime = data?.uptime ?? [{}]
return (
<>
-
+
System status
{' '}
-
- {/* {(showAllItems || cardState.cardSize === 'small') && (
- <>
-
-
-
- >
+ {showAllItems && (
+
+
+
)}
-
*/}
- {!loading && cardState.cardSize !== 'small' && (
+
+ {!loading && (
<>
+ {/*
+ On hold until system uptime is implemented
-
+
{parseUptime(uptime[0].time)}
- System up time
+ System up time
+ */}
+
+ {data?.serverVersion}
+ server version
- {data?.serverVersion}
- server version
-
-
- {/* console.log('Upgrade button clicked')}>
@@ -136,18 +96,22 @@ const SystemStatus = ({ cardState, setRightSideState }) => {
*/}
-
+
- {/* {showExpandButton && (
+ {!showAllItems && data.machines.length > NUM_TO_RENDER && (
<>
-
+
>
- )} */}
+ )}
>
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js
index 8fbb7de4..9cf06374 100644
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js
+++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js
@@ -115,23 +115,19 @@ const CashCassettes = ({ machine, config, refetchData }) => {
})
}
- return (
- <>
- {machine.name && (
-
- )}
- >
- )
+ return machine.name ? (
+
+ ) : null
}
export default CashCassettes
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Commissions/Commissions.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Commissions/Commissions.js
index 28fc8861..6b569961 100644
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Commissions/Commissions.js
+++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Commissions/Commissions.js
@@ -86,17 +86,15 @@ const Commissions = ({ name: SCREEN_KEY, id: deviceId }) => {
return R.values(commissions)
}
- getMachineCommissions()
+ const machineCommissions = getMachineCommissions()
return (
- <>
-
- >
+
)
}
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Details.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Details.js
index 32c65d01..a47adfc7 100644
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Details.js
+++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Details.js
@@ -10,28 +10,24 @@ const useStyles = makeStyles(styles)
const Details = ({ data }) => {
const classes = useStyles()
return (
- <>
-
-
- {' '}
-
Paired at
-
- {data.pairedAt
- ? moment(data.pairedAt).format('YYYY-MM-DD HH:mm:ss')
- : ''}
-
-
-
-
Machine model
-
{data.model}
-
-
- {' '}
-
Software version
-
{data.version}
-
+
+
+
Paired at
+
+ {data.pairedAt
+ ? moment(data.pairedAt).format('YYYY-MM-DD HH:mm:ss')
+ : ''}
+
- >
+
+
Machine model
+
{data.model}
+
+
+
Software version
+
{data.version}
+
+
)
}
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.js
index 6b2e50a3..11f9f295 100644
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.js
+++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Overview.js
@@ -30,6 +30,25 @@ const MACHINE_ACTION = gql`
}
`
+const makeLastPing = lastPing => {
+ if (!lastPing) return null
+ const now = moment()
+ const secondsAgo = now.diff(lastPing, 'seconds')
+ if (secondsAgo < 60) {
+ return `${secondsAgo} ${secondsAgo === 1 ? 'second' : 'seconds'} ago`
+ }
+ if (secondsAgo < 3600) {
+ const minutes = Math.round(secondsAgo / 60)
+ return `${minutes} ${minutes === 1 ? 'minute' : 'minutes'} ago`
+ }
+ if (secondsAgo < 3600 * 24) {
+ const hours = Math.round(secondsAgo / 3600)
+ return `${hours} ${hours === 1 ? 'hour' : 'hours'} ago`
+ }
+ const days = Math.round(secondsAgo / 3600 / 24)
+ return `${days} ${days === 1 ? 'day' : 'days'} ago`
+}
+
const Overview = ({ data, onActionSuccess }) => {
const [action, setAction] = useState('')
const [confirmActionDialogOpen, setConfirmActionDialogOpen] = useState(false)
@@ -50,24 +69,6 @@ const Overview = ({ data, onActionSuccess }) => {
const confirmActionDialog = action =>
setAction(action) || setConfirmActionDialogOpen(true)
- const makeLastPing = () => {
- const now = moment()
- const secondsAgo = now.diff(data.lastPing, 'seconds')
- if (secondsAgo < 60) {
- return `${secondsAgo} ${secondsAgo === 1 ? 'second' : 'seconds'} ago`
- }
- if (secondsAgo < 3600) {
- const minutes = Math.round(secondsAgo / 60)
- return `${minutes} ${minutes === 1 ? 'minute' : 'minutes'} ago`
- }
- if (secondsAgo < 3600 * 24) {
- const hours = Math.round(secondsAgo / 3600)
- return `${hours} ${hours === 1 ? 'hour' : 'hours'} ago`
- }
- const days = Math.round(secondsAgo / 3600 / 24)
- return `${days} ${days === 1 ? 'day' : 'days'} ago`
- }
-
return (
<>
@@ -84,7 +85,7 @@ const Overview = ({ data, onActionSuccess }) => {
Last ping
-
{data.lastPing ? makeLastPing() : ''}
+
{makeLastPing(data.lastPing)}
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/CopyToClipboard.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/CopyToClipboard.js
deleted file mode 100644
index ce6065c6..00000000
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/CopyToClipboard.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import { makeStyles } from '@material-ui/core/styles'
-import classnames from 'classnames'
-import * as R from 'ramda'
-import React, { useState, useEffect } from 'react'
-import { CopyToClipboard as ReactCopyToClipboard } from 'react-copy-to-clipboard'
-
-import Popover from 'src/components/Popper'
-import { ReactComponent as CopyIcon } from 'src/styling/icons/action/copy/copy.svg'
-import { comet } from 'src/styling/variables'
-
-import { cpcStyles } from './Transactions.styles'
-
-const useStyles = makeStyles(cpcStyles)
-
-const CopyToClipboard = ({
- className,
- buttonClassname,
- children,
- ...props
-}) => {
- const [anchorEl, setAnchorEl] = useState(null)
-
- useEffect(() => {
- if (anchorEl) setTimeout(() => setAnchorEl(null), 3000)
- }, [anchorEl])
-
- const classes = useStyles()
-
- const handleClick = event => {
- setAnchorEl(anchorEl ? null : event.currentTarget)
- }
-
- const handleClose = () => {
- setAnchorEl(null)
- }
-
- const open = Boolean(anchorEl)
- const id = open ? 'simple-popper' : undefined
-
- return (
-
- {children && (
- <>
-
- {children}
-
-
-
-
-
-
-
-
-
- >
- )}
-
- )
-}
-
-export default CopyToClipboard
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.js
index 18552260..55bef3af 100644
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.js
+++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.js
@@ -17,12 +17,11 @@ import {
Td,
Th
} from 'src/components/fake-table/Table'
+import styles from 'src/components/tables/DataTable.styles'
import { H4 } from 'src/components/typography'
import { ReactComponent as ExpandClosedIcon } from 'src/styling/icons/action/expand/closed.svg'
import { ReactComponent as ExpandOpenIcon } from 'src/styling/icons/action/expand/open.svg'
-import styles from './DataTable.styles'
-
const useStyles = makeStyles(styles)
const Row = ({
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.styles.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.styles.js
deleted file mode 100644
index de57aca7..00000000
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.styles.js
+++ /dev/null
@@ -1,45 +0,0 @@
-import { zircon } from 'src/styling/variables'
-
-const styles = {
- expandButton: {
- outline: 'none',
- border: 'none',
- backgroundColor: 'transparent',
- cursor: 'pointer',
- padding: 4
- },
- rowWrapper: {
- // workaround to shadows cut by r-virtualized when scroll is visible
- padding: 1
- },
- row: {
- border: [[2, 'solid', 'transparent']],
- borderRadius: 0
- },
- expanded: {
- border: [[2, 'solid', zircon]],
- boxShadow: '0 0 8px 0 rgba(0,0,0,0.08)'
- },
- before: {
- paddingTop: 12
- },
- after: {
- paddingBottom: 12
- },
- pointer: {
- cursor: 'pointer'
- },
- body: {
- flex: [[1, 1, 'auto']]
- },
- table: ({ width }) => ({
- marginBottom: 30,
- minHeight: 200,
- width,
- flex: 1,
- display: 'flex',
- flexDirection: 'column'
- })
-}
-
-export default styles
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DetailsCard.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DetailsCard.js
deleted file mode 100644
index 6dc282f5..00000000
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DetailsCard.js
+++ /dev/null
@@ -1,195 +0,0 @@
-import { makeStyles, Box } from '@material-ui/core'
-import BigNumber from 'bignumber.js'
-import moment from 'moment'
-import React, { memo } from 'react'
-
-import { IDButton } from 'src/components/buttons'
-import { Label1 } from 'src/components/typography'
-import { ReactComponent as CardIdInverseIcon } from 'src/styling/icons/ID/card/white.svg'
-import { ReactComponent as CardIdIcon } from 'src/styling/icons/ID/card/zodiac.svg'
-import { ReactComponent as PhoneIdInverseIcon } from 'src/styling/icons/ID/phone/white.svg'
-import { ReactComponent as PhoneIdIcon } from 'src/styling/icons/ID/phone/zodiac.svg'
-import { ReactComponent as CamIdInverseIcon } from 'src/styling/icons/ID/photo/white.svg'
-import { ReactComponent as CamIdIcon } from 'src/styling/icons/ID/photo/zodiac.svg'
-import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg'
-import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
-import { URI } from 'src/utils/apollo'
-import { toUnit, formatCryptoAddress } from 'src/utils/coin'
-import { onlyFirstToUpper } from 'src/utils/string'
-
-import CopyToClipboard from './CopyToClipboard'
-import styles from './DetailsCard.styles'
-import { getStatus } from './helper'
-
-const useStyles = makeStyles(styles)
-
-const formatAddress = (cryptoCode = '', address = '') =>
- formatCryptoAddress(cryptoCode, address).replace(/(.{5})/g, '$1 ')
-
-const Label = ({ children }) => {
- const classes = useStyles()
- return
{children}
-}
-
-const DetailsRow = ({ it: tx }) => {
- const classes = useStyles()
-
- const fiat = Number.parseFloat(tx.fiat)
- const crypto = toUnit(new BigNumber(tx.cryptoAtoms), tx.cryptoCode)
- const commissionPercentage = Number.parseFloat(tx.commissionPercentage, 2)
- const commission = Number(fiat * commissionPercentage).toFixed(2)
- const exchangeRate = Number(fiat / crypto).toFixed(3)
- const displayExRate = `1 ${tx.cryptoCode} = ${exchangeRate} ${tx.fiatCode}`
-
- const customer = tx.customerIdCardData && {
- name: `${onlyFirstToUpper(
- tx.customerIdCardData.firstName
- )} ${onlyFirstToUpper(tx.customerIdCardData.lastName)}`,
- age: moment().diff(moment(tx.customerIdCardData.dateOfBirth), 'years'),
- country: tx.customerIdCardData.country,
- idCardNumber: tx.customerIdCardData.documentNumber,
- idCardExpirationDate: moment(tx.customerIdCardData.expirationDate).format(
- 'DD-MM-YYYY'
- )
- }
-
- return (
-
-
-
-
-
-
- {tx.txClass === 'cashOut' ? : }
-
- {tx.txClass === 'cashOut' ? 'Cash-out' : 'Cash-in'}
-
-
-
-
-
-
- {tx.customerPhone && (
-
- {tx.customerPhone}
-
- )}
- {tx.customerIdCardPhotoPath && !tx.customerIdCardData && (
-
-
-
- )}
- {tx.customerIdCardData && (
-
-
-
-
-
-
{customer.name}
-
-
-
-
-
{customer.country}
-
-
-
-
-
-
{customer.idCardNumber}
-
-
-
-
{customer.idCardExpirationDate}
-
-
-
-
- )}
- {tx.customerFrontCameraPath && (
-
-
-
- )}
-
-
-
-
-
{crypto > 0 ? displayExRate : '-'}
-
-
-
-
- {`${commission} ${tx.fiatCode} (${commissionPercentage * 100} %)`}
-
-
-
-
-
- {tx.txClass === 'cashIn'
- ? `${Number.parseFloat(tx.cashInFee)} ${tx.fiatCode}`
- : 'N/A'}
-
-
-
-
-
-
-
-
- {formatAddress(tx.cryptoCode, tx.toAddress)}
-
-
-
-
-
-
- {tx.txClass === 'cashOut' ? (
- 'N/A'
- ) : (
- {tx.txHash}
- )}
-
-
-
-
- {tx.id}
-
-
-
-
-
- {getStatus(tx)}
-
-
-
- )
-}
-
-export default memo(DetailsRow, (prev, next) => prev.id === next.id)
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DetailsCard.styles.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DetailsCard.styles.js
deleted file mode 100644
index 71969897..00000000
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DetailsCard.styles.js
+++ /dev/null
@@ -1,86 +0,0 @@
-import typographyStyles from 'src/components/typography/styles'
-import { offColor } from 'src/styling/variables'
-
-const { p } = typographyStyles
-
-const styles = {
- wrapper: {
- display: 'flex',
- flexDirection: 'column',
- marginTop: 24
- },
- row: {
- display: 'flex',
- flexDirection: 'row',
- marginBottom: 36
- },
- secondRow: {
- display: 'flex',
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginBottom: 36
- },
- lastRow: {
- display: 'flex',
- flexDirection: 'row',
- marginBottom: 32
- },
- label: {
- color: offColor,
- margin: [[0, 0, 6, 0]]
- },
- txIcon: {
- marginRight: 10
- },
- popover: {
- height: 164,
- width: 215
- },
- idButton: {
- marginRight: 4
- },
- idCardDataCard: {
- extend: p,
- display: 'flex',
- padding: [[11, 8]],
- // rework this into a proper component
- '& > div': {
- display: 'flex',
- flexDirection: 'column',
- '& > div': {
- width: 144,
- height: 37,
- marginBottom: 15,
- '&:last-child': {
- marginBottom: 0
- }
- }
- }
- },
- bold: {
- fontWeight: 700
- },
- direction: {
- width: 233
- },
- availableIds: {
- width: 232
- },
- exchangeRate: {
- width: 250
- },
- commission: {
- width: 217
- },
- address: {
- width: 280
- },
- transactionId: {
- width: 280
- },
- sessionId: {
- width: 215
- }
-}
-
-export default styles
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Stripes.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Stripes.js
deleted file mode 100644
index 59cf8ce6..00000000
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Stripes.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import React from 'react'
-
-import { Td } from 'src/components/fake-table/Table'
-import { ReactComponent as StripesSvg } from 'src/styling/icons/stripes.svg'
-
-const Stripes = ({ width }) => (
-
-
- |
-)
-
-export default Stripes
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js
index 949eaa37..75e6f6f7 100644
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js
+++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/Transactions.js
@@ -6,22 +6,26 @@ import moment from 'moment'
import * as R from 'ramda'
import React, { useEffect, useState } from 'react'
+import DetailsRow from 'src/pages/Transactions/DetailsCard'
+import { mainStyles } from 'src/pages/Transactions/Transactions.styles'
+import { getStatus } from 'src/pages/Transactions/helper'
import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg'
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
import { toUnit, formatCryptoAddress } from 'src/utils/coin'
import DataTable from './DataTable'
-import DetailsRow from './DetailsCard'
-import { mainStyles } from './Transactions.styles'
-import { getStatus } from './helper'
-
const useStyles = makeStyles(mainStyles)
const NUM_LOG_RESULTS = 5
const GET_TRANSACTIONS = gql`
- query transactions($limit: Int, $from: Date, $until: Date, $id: ID) {
- transactions(limit: $limit, from: $from, until: $until, id: $id) {
+ query transactions($limit: Int, $from: Date, $until: Date, $deviceId: ID) {
+ transactions(
+ limit: $limit
+ from: $from
+ until: $until
+ deviceId: $deviceId
+ ) {
id
txClass
txHash
@@ -61,7 +65,7 @@ const Transactions = ({ id }) => {
{
variables: {
limit: NUM_LOG_RESULTS,
- id
+ deviceId: id
}
}
)
diff --git a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/helper.js b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/helper.js
deleted file mode 100644
index 91c0a7b9..00000000
--- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/helper.js
+++ /dev/null
@@ -1,23 +0,0 @@
-const getCashOutStatus = it => {
- if (it.hasError) return 'Error'
- if (it.dispense) return 'Success'
- if (it.expired) return 'Expired'
- return 'Pending'
-}
-
-const getCashInStatus = it => {
- if (it.operatorCompleted) return 'Cancelled'
- if (it.hasError) return 'Error'
- if (it.sendConfirmed) return 'Sent'
- if (it.expired) return 'Expired'
- return 'Pending'
-}
-
-const getStatus = it => {
- if (it.class === 'cashOut') {
- return getCashOutStatus(it)
- }
- return getCashInStatus(it)
-}
-
-export { getStatus }
diff --git a/new-lamassu-admin/src/pages/Machines/MachineSidebar.js b/new-lamassu-admin/src/pages/Machines/MachineSidebar.js
index 24761137..6a0a2927 100644
--- a/new-lamassu-admin/src/pages/Machines/MachineSidebar.js
+++ b/new-lamassu-admin/src/pages/Machines/MachineSidebar.js
@@ -1,11 +1,15 @@
import List from '@material-ui/core/List'
import ListItem from '@material-ui/core/ListItem'
import ListItemText from '@material-ui/core/ListItemText'
+import { makeStyles } from '@material-ui/core/styles'
import React from 'react'
+import styles from './Machines.styles'
+const useStyles = makeStyles(styles)
const MachineSidebar = ({ data, getText, getKey, isSelected, selectItem }) => {
+ const classes = useStyles()
return (
-
+
{data.map((item, idx) => {
return (
{
})}
)
-
- /* return data.map(item => ) */
}
export default MachineSidebar
diff --git a/new-lamassu-admin/src/pages/Machines/Machines.js b/new-lamassu-admin/src/pages/Machines/Machines.js
index f3a54e91..43914f98 100644
--- a/new-lamassu-admin/src/pages/Machines/Machines.js
+++ b/new-lamassu-admin/src/pages/Machines/Machines.js
@@ -3,6 +3,7 @@ import Breadcrumbs from '@material-ui/core/Breadcrumbs'
import Grid from '@material-ui/core/Grid'
import { makeStyles } from '@material-ui/core/styles'
import NavigateNextIcon from '@material-ui/icons/NavigateNext'
+import classnames from 'classnames'
import gql from 'graphql-tag'
import * as R from 'ramda'
import React, { useState, useEffect } from 'react'
@@ -66,59 +67,58 @@ const Machines = () => {
}, [loading, data, location.state])
return (
- <>
-
-
-
-
- }>
-
- Dashboard
-
- {selectedMachine}
-
-
-
-
-
-
-
-
-
-
-
- {'Details'}
-
-
-
- {'Cash cassettes'}
-
-
-
- {'Latest transactions'}
-
-
-
- {'Commissions'}
-
-
+
+
+
+
+ }>
+
+ Dashboard
+
+ {selectedMachine}
+
+
+
+
+
- >
+
+
+
+ {'Details'}
+
+
+
+ {'Cash cassettes'}
+
+
+
+ {'Latest transactions'}
+
+
+
+ {'Commissions'}
+
+
+
+
+
)
}
diff --git a/new-lamassu-admin/src/pages/Machines/Machines.styles.js b/new-lamassu-admin/src/pages/Machines/Machines.styles.js
index efbb6492..f0e1ad63 100644
--- a/new-lamassu-admin/src/pages/Machines/Machines.styles.js
+++ b/new-lamassu-admin/src/pages/Machines/Machines.styles.js
@@ -69,6 +69,19 @@ const styles = {
},
actionButton: {
marginRight: 8
+ },
+ breadcrumbsContainer: {
+ marginTop: 32
+ },
+ breadcrumbLink: {
+ textDecoration: 'none'
+ },
+ detailsMargin: {
+ marginTop: 24
+ },
+ sidebarContainer: {
+ height: 400,
+ overflowY: 'auto'
}
}
diff --git a/new-lamassu-admin/src/routing/routes.js b/new-lamassu-admin/src/routing/routes.js
index eb6deab2..9bd5f879 100644
--- a/new-lamassu-admin/src/routing/routes.js
+++ b/new-lamassu-admin/src/routing/routes.js
@@ -51,18 +51,6 @@ const useStyles = makeStyles({
})
const tree = [
- /* {
- key: 'dashboard',
- label: 'Dashboard',
- route: '/dashboard',
- component: Dashboard
- }, */
- /* {
- key: 'machines',
- label: 'Machines',
- route: '/machines',
- component: Machines
- }, */
{
key: 'transactions',
label: 'Transactions',
diff --git a/new-lamassu-admin/src/styling/theme.js b/new-lamassu-admin/src/styling/theme.js
index fdac109f..7fed1fa2 100644
--- a/new-lamassu-admin/src/styling/theme.js
+++ b/new-lamassu-admin/src/styling/theme.js
@@ -108,6 +108,13 @@ export default createMuiTheme({
color: fontColor
}
}
+ },
+ MuiListItem: {
+ root: {
+ '&:nth-of-type(odd)': {
+ backgroundColor: backgroundColor
+ }
+ }
}
}
})
diff --git a/new-lamassu-admin/src/utils/sanctuary.js b/new-lamassu-admin/src/utils/sanctuary.js
index 1b31fac2..9172e6a9 100644
--- a/new-lamassu-admin/src/utils/sanctuary.js
+++ b/new-lamassu-admin/src/utils/sanctuary.js
@@ -1,7 +1,7 @@
import * as sanctuary from 'sanctuary'
const checkOnlyDev = () => {
- if (!process.env.NODE_ENV === 'production') return false
+ if (process.env.NODE_ENV !== 'production') return false
return (
process.env.NODE_ENV === 'development' &&