fix: machines/:id routing

This commit is contained in:
Rafael Taranto 2025-05-16 08:15:51 +01:00
parent a3dc450497
commit 8405d23dee
2 changed files with 5 additions and 7 deletions

View file

@ -3,7 +3,7 @@ import Breadcrumbs from '@mui/material/Breadcrumbs'
import NavigateNextIcon from '@mui/icons-material/NavigateNext'
import * as R from 'ramda'
import React, { useState } from 'react'
import { Link, useLocation } from 'wouter'
import { Link, useLocation, useParams } from 'wouter'
import { TL1, TL2, Label3 } from '../../components/typography'
import Cassettes from './MachineComponents/Cassettes'
@ -58,13 +58,11 @@ const GET_INFO = gql`
}
`
const getMachineID = path => path.slice(path.lastIndexOf('/') + 1)
const MachineRoute = () => {
const [location, navigate] = useLocation()
const [loading, setLoading] = useState(true)
const { id: deviceId } = useParams()
const id = getMachineID(location)
const { data, refetch } = useQuery(GET_INFO, {
onCompleted: data => {
if (data.machine === null) return navigate('/maintenance/machine-status')
@ -72,9 +70,9 @@ const MachineRoute = () => {
setLoading(false)
},
variables: {
deviceId: id,
deviceId,
billFilters: {
deviceId: id,
deviceId,
batch: 'none',
},
},

View file

@ -93,7 +93,7 @@ const Routes = () => {
</div>
</Transition>
</PrivateRoute>
<PrivateRoute path="/machines">
<PrivateRoute path="/machines/:id">
<Machines />
</PrivateRoute>
<PublicRoute path="/register" component={Register} />