fix: machines/:id routing
This commit is contained in:
parent
a3dc450497
commit
8405d23dee
2 changed files with 5 additions and 7 deletions
|
|
@ -3,7 +3,7 @@ import Breadcrumbs from '@mui/material/Breadcrumbs'
|
||||||
import NavigateNextIcon from '@mui/icons-material/NavigateNext'
|
import NavigateNextIcon from '@mui/icons-material/NavigateNext'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { Link, useLocation } from 'wouter'
|
import { Link, useLocation, useParams } from 'wouter'
|
||||||
import { TL1, TL2, Label3 } from '../../components/typography'
|
import { TL1, TL2, Label3 } from '../../components/typography'
|
||||||
|
|
||||||
import Cassettes from './MachineComponents/Cassettes'
|
import Cassettes from './MachineComponents/Cassettes'
|
||||||
|
|
@ -58,13 +58,11 @@ const GET_INFO = gql`
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const getMachineID = path => path.slice(path.lastIndexOf('/') + 1)
|
|
||||||
|
|
||||||
const MachineRoute = () => {
|
const MachineRoute = () => {
|
||||||
const [location, navigate] = useLocation()
|
const [location, navigate] = useLocation()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const { id: deviceId } = useParams()
|
||||||
|
|
||||||
const id = getMachineID(location)
|
|
||||||
const { data, refetch } = useQuery(GET_INFO, {
|
const { data, refetch } = useQuery(GET_INFO, {
|
||||||
onCompleted: data => {
|
onCompleted: data => {
|
||||||
if (data.machine === null) return navigate('/maintenance/machine-status')
|
if (data.machine === null) return navigate('/maintenance/machine-status')
|
||||||
|
|
@ -72,9 +70,9 @@ const MachineRoute = () => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
},
|
},
|
||||||
variables: {
|
variables: {
|
||||||
deviceId: id,
|
deviceId,
|
||||||
billFilters: {
|
billFilters: {
|
||||||
deviceId: id,
|
deviceId,
|
||||||
batch: 'none',
|
batch: 'none',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ const Routes = () => {
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
<PrivateRoute path="/machines">
|
<PrivateRoute path="/machines/:id">
|
||||||
<Machines />
|
<Machines />
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
<PublicRoute path="/register" component={Register} />
|
<PublicRoute path="/register" component={Register} />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue