diff --git a/new-lamassu-admin/src/components/layout/Header.js b/new-lamassu-admin/src/components/layout/Header.js
index b5424936..97ae6995 100644
--- a/new-lamassu-admin/src/components/layout/Header.js
+++ b/new-lamassu-admin/src/components/layout/Header.js
@@ -44,7 +44,7 @@ const Header = memo(({ tree }) => {
const onPaired = machine => {
setOpen(false)
- history.push(`/maintenance/machine-status/${machine.deviceId}`)
+ history.push('/maintenance/machine-status', { id: machine.deviceId })
}
return (
diff --git a/new-lamassu-admin/src/components/tables/DataTable.js b/new-lamassu-admin/src/components/tables/DataTable.js
index 2891f688..5d8a55ca 100644
--- a/new-lamassu-admin/src/components/tables/DataTable.js
+++ b/new-lamassu-admin/src/components/tables/DataTable.js
@@ -1,7 +1,7 @@
import { makeStyles, Box } from '@material-ui/core'
import classnames from 'classnames'
import * as R from 'ramda'
-import React, { useState } from 'react'
+import React, { useState, useEffect } from 'react'
import {
AutoSizer,
List,
@@ -93,13 +93,15 @@ const DataTable = ({
Details,
className,
expandable,
- shouldStartExpanded,
+ initialExpanded,
onClick,
loading,
emptyText,
...props
}) => {
- const [expanded, setExpanded] = useState(null)
+ const [expanded, setExpanded] = useState(initialExpanded)
+
+ useEffect(() => setExpanded(initialExpanded), [initialExpanded])
const coreWidth = R.compose(R.sum, R.map(R.prop('width')))(elements)
const expWidth = 1200 - coreWidth
@@ -132,10 +134,7 @@ const DataTable = ({
elements={elements}
data={data[index]}
Details={Details}
- expanded={
- index === expanded ||
- (shouldStartExpanded && shouldStartExpanded(data[index]))
- }
+ expanded={index === expanded}
expandRow={expandRow}
expandable={expandable}
onClick={onClick}
diff --git a/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js b/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js
index 0e71fefc..b2af1563 100644
--- a/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js
+++ b/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js
@@ -87,8 +87,9 @@ const MachineDetailsRow = ({ it: machine, onActionSuccess }) => {
setErrorMessage(errorMessage)
},
onCompleted: () => {
- onActionSuccess ? onActionSuccess() : window.location.reload()
- setConfirmActionDialogOpen(false)
+ onActionSuccess && onActionSuccess()
+ renameActionDialogOpen && setConfirmActionDialogOpen(false)
+ confirmActionDialogOpen && setRenameActionDialogOpen(false)
}
})
diff --git a/new-lamassu-admin/src/pages/Maintenance/MachineStatus.js b/new-lamassu-admin/src/pages/Maintenance/MachineStatus.js
index 8d27f2e2..3e459e02 100644
--- a/new-lamassu-admin/src/pages/Maintenance/MachineStatus.js
+++ b/new-lamassu-admin/src/pages/Maintenance/MachineStatus.js
@@ -4,7 +4,7 @@ import gql from 'graphql-tag'
import moment from 'moment'
import * as R from 'ramda'
import React from 'react'
-import { useParams } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
import { MainStatus } from 'src/components/Status'
import Title from 'src/components/Title'
@@ -41,10 +41,9 @@ const useStyles = makeStyles(mainStyles)
const MachineStatus = () => {
const classes = useStyles()
- const { id: machineId } = useParams()
- const { data: machinesResponse } = useQuery(GET_MACHINES)
-
- const shouldStartExpanded = machine => machine.deviceId === machineId
+ const { state } = useLocation()
+ const addedMachineId = state?.id
+ const { data: machinesResponse, refetch } = useQuery(GET_MACHINES)
const elements = [
{
@@ -77,6 +76,15 @@ const MachineStatus = () => {
}
]
+ const machines = R.path(['machines'])(machinesResponse) ?? []
+ const expandedIndex = R.findIndex(R.propEq('deviceId', addedMachineId))(
+ machines
+ )
+
+ const InnerMachineDetailsRow = ({ it }) => (
+