Merge pull request #1852 from RafaelTaranto/fix/id-routing
fix: id routing
This commit is contained in:
commit
942a1843d4
3 changed files with 10 additions and 9 deletions
|
|
@ -285,7 +285,6 @@ const CHECK_AGAINST_SANCTIONS = gql`
|
||||||
|
|
||||||
const CustomerProfile = memo(() => {
|
const CustomerProfile = memo(() => {
|
||||||
const [, navigate] = useLocation()
|
const [, navigate] = useLocation()
|
||||||
|
|
||||||
const [showCompliance, setShowCompliance] = useState(false)
|
const [showCompliance, setShowCompliance] = useState(false)
|
||||||
const [wizard, setWizard] = useState(false)
|
const [wizard, setWizard] = useState(false)
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
|
|
@ -298,6 +297,7 @@ const CustomerProfile = memo(() => {
|
||||||
loading: customerLoading,
|
loading: customerLoading,
|
||||||
} = useQuery(GET_CUSTOMER, {
|
} = useQuery(GET_CUSTOMER, {
|
||||||
variables: { customerId },
|
variables: { customerId },
|
||||||
|
skip: !customerId,
|
||||||
})
|
})
|
||||||
|
|
||||||
const { data: configResponse, loading: configLoading } = useQuery(GET_DATA)
|
const { data: configResponse, loading: configLoading } = useQuery(GET_DATA)
|
||||||
|
|
|
||||||
|
|
@ -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} />
|
||||||
|
|
@ -105,7 +105,10 @@ const Routes = () => {
|
||||||
<Transition
|
<Transition
|
||||||
className={wrapperClasses}
|
className={wrapperClasses}
|
||||||
{...transitionProps}
|
{...transitionProps}
|
||||||
in={location === route}
|
in={
|
||||||
|
location === route ||
|
||||||
|
(route.includes(':') && location.startsWith(route.split(':')[0]))
|
||||||
|
}
|
||||||
mountOnEnter
|
mountOnEnter
|
||||||
unmountOnExit>
|
unmountOnExit>
|
||||||
<div className={wrapperClasses}>
|
<div className={wrapperClasses}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue