import * as R from 'ramda' import React, { memo, useState } from 'react' import GraphTooltip from '../components/tooltips/GraphTooltip' import HourOfDayBarGraph from './HourOfDayBarGraph' import OverTimeDotGraph from './OverTimeDotGraph' import OverTimeLineGraph from './OverTimeLineGraph' import TopMachinesBarGraph from './TopMachinesBarGraph' const GraphWrapper = ({ data, representing, period, timezone, currency, selectedMachine, machines, selectedDay, log }) => { const [selectionCoords, setSelectionCoords] = useState(null) const [selectionDateInterval, setSelectionDateInterval] = useState(null) const [selectionData, setSelectionData] = useState(null) const getGraph = representing => { switch (representing.code) { case 'overTime': return ( ) case 'volumeOverTime': return ( ) case 'topMachinesVolume': return ( it.code !== 'all', machines)} currency={currency} /> ) case 'topMachinesTransactions': return ( it.code !== 'all', machines)} currency={currency} /> ) case 'hourOfDayVolume': return ( it.code !== 'all', machines)} currency={currency} selectedDay={selectedDay} /> ) case 'hourOfDayTransactions': return ( it.code !== 'all', machines)} currency={currency} selectedDay={selectedDay} /> ) default: throw new Error(`There's no graph to represent ${representing}`) } } return (
{!R.isNil(selectionCoords) && ( )} {getGraph(representing)}
) } export default memo(GraphWrapper)