From 91e6ba4e66247155ba3a3d72575a823489c218e4 Mon Sep 17 00:00:00 2001 From: csrapr <26280794+csrapr@users.noreply.github.com> Date: Tue, 23 Mar 2021 16:37:21 +0000 Subject: [PATCH 1/4] Chore: remove unneeded useEffect and useState hooks --- .../src/pages/Machines/Machines.js | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/new-lamassu-admin/src/pages/Machines/Machines.js b/new-lamassu-admin/src/pages/Machines/Machines.js index a3b73814..75e87c2c 100644 --- a/new-lamassu-admin/src/pages/Machines/Machines.js +++ b/new-lamassu-admin/src/pages/Machines/Machines.js @@ -6,7 +6,7 @@ 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' +import React from 'react' import { Link, useLocation } from 'react-router-dom' import { TL1, TL2, Label3 } from 'src/components/typography' @@ -46,25 +46,17 @@ const GET_INFO = gql` const getMachines = R.path(['machines']) const Machines = () => { - const { data, refetch, loading } = useQuery(GET_INFO) + const { data, refetch } = useQuery(GET_INFO) const location = useLocation() - const [selectedMachine, setSelectedMachine] = useState('') const classes = useStyles() + const selectedMachine = + R.path(['state', 'selectedMachine'])(location) ?? + R.path(['machines', 0, 'name'])(data) ?? + '' const machines = getMachines(data) ?? [] const machineInfo = getMachineInfo(selectedMachine)(machines) ?? {} - // pre-selects first machine from the list, if there is a machine configured. - useEffect(() => { - if (!loading && data && data.machines) { - if (location.state && location.state.selectedMachine) { - setSelectedMachine(location.state.selectedMachine) - } else { - setSelectedMachine(R.path(['machines', 0, 'name'])(data) ?? '') - } - } - }, [loading, data, location.state]) - return ( From 10794f5ccf5282649e25ead1f0af79c3ec083b9b Mon Sep 17 00:00:00 2001 From: csrapr <26280794+csrapr@users.noreply.github.com> Date: Tue, 23 Mar 2021 16:49:33 +0000 Subject: [PATCH 2/4] Fix: disable editing in cash cassettes --- .../src/pages/Machines/MachineComponents/Cassettes/Cassettes.js | 1 - 1 file changed, 1 deletion(-) 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 8779fe64..f85f4e21 100644 --- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js +++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js @@ -145,7 +145,6 @@ const CashCassettes = ({ machine, config, refetchData }) => { disableRowEdit={isCashOutDisabled} name="cashboxes" elements={elements} - enableEdit data={[machine] || []} save={onSave} validationSchema={ValidationSchema} From 340951f924fee85f99f451a4ef071a879156ec04 Mon Sep 17 00:00:00 2001 From: csrapr <26280794+csrapr@users.noreply.github.com> Date: Tue, 23 Mar 2021 16:52:04 +0000 Subject: [PATCH 3/4] Fix: cashbox should always be visible --- .../src/pages/Machines/MachineComponents/Cassettes/Cassettes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f85f4e21..26e2ac4d 100644 --- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js +++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Cassettes/Cassettes.js @@ -73,7 +73,7 @@ const CashCassettes = ({ machine, config, refetchData }) => { name: 'cashbox', header: 'Cashbox', width: 240, - stripe: true, + stripe: false, view: value => ( ), From ee84386e95c47cd009970e13ded69b587765fd67 Mon Sep 17 00:00:00 2001 From: csrapr <26280794+csrapr@users.noreply.github.com> Date: Tue, 23 Mar 2021 18:01:06 +0000 Subject: [PATCH 4/4] Fix: broken header when horizontal scrolling --- .../MachineComponents/Transactions/DataTable.js | 4 ++-- .../Transactions/Transactions.js | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) 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 55bef3af..d5636b53 100644 --- a/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.js +++ b/new-lamassu-admin/src/pages/Machines/MachineComponents/Transactions/DataTable.js @@ -104,7 +104,7 @@ const DataTable = ({ useEffect(() => setExpanded(initialExpanded), [initialExpanded]) const coreWidth = R.compose(R.sum, R.map(R.prop('width')))(elements) - const expWidth = 1000 - coreWidth + const expWidth = 850 - coreWidth const width = coreWidth + (expandable ? expWidth : 0) const classes = useStyles({ width }) @@ -166,7 +166,7 @@ const DataTable = ({ {() => ( { const elements = [ { header: '', - width: 62, + width: 0, size: 'sm', view: it => (it.txClass === 'cashOut' ? : ) }, { header: 'Customer', - width: 162, + width: 122, size: 'sm', view: getCustomerDisplayName }, @@ -128,20 +131,20 @@ const Transactions = ({ id }) => { className: classes.overflowTd, size: 'sm', textAlign: 'left', - width: 170 + width: 140 }, { header: 'Date (UTC)', view: it => moment.utc(it.created).format('YYYY-MM-DD'), textAlign: 'left', size: 'sm', - width: 150 + width: 140 }, { header: 'Status', view: it => getStatus(it), size: 'sm', - width: 80 + width: 20 } ] @@ -162,8 +165,7 @@ const Transactions = ({ id }) => { loading={loading || id === null} emptyText="No transactions so far" elements={elements} - // need to splice because back end query could return double NUM_LOG_RESULTS because it doesnt merge the txIn and the txOut results before applying the limit - data={R.path(['transactions'])(txResponse)} // .splice(0,NUM_LOG_RESULTS)} + data={R.path(['transactions'])(txResponse)} Details={DetailsRow} expandable />