2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Panel index fix (#6255)

* Fix panel routing for part category index

* Fix routing for stock location index
This commit is contained in:
Oliver 2024-01-16 22:12:28 +11:00 committed by GitHub
parent fa28697799
commit 8eec2f32c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -23,7 +23,11 @@ import { useInstance } from '../../hooks/UseInstance';
* Note: If no category ID is supplied, this acts as the top-level part category page * Note: If no category ID is supplied, this acts as the top-level part category page
*/ */
export default function CategoryDetail({}: {}) { export default function CategoryDetail({}: {}) {
const { id } = useParams(); const { id: _id } = useParams();
const id = useMemo(
() => (!isNaN(parseInt(_id || '')) ? _id : undefined),
[_id]
);
const [treeOpen, setTreeOpen] = useState(false); const [treeOpen, setTreeOpen] = useState(false);
@ -33,6 +37,7 @@ export default function CategoryDetail({}: {}) {
instanceQuery instanceQuery
} = useInstance({ } = useInstance({
endpoint: ApiPaths.category_list, endpoint: ApiPaths.category_list,
hasPrimaryKey: true,
pk: id, pk: id,
params: { params: {
path_detail: true path_detail: true

View File

@ -13,7 +13,12 @@ import { ApiPaths } from '../../enums/ApiEndpoints';
import { useInstance } from '../../hooks/UseInstance'; import { useInstance } from '../../hooks/UseInstance';
export default function Stock() { export default function Stock() {
const { id } = useParams(); const { id: _id } = useParams();
const id = useMemo(
() => (!isNaN(parseInt(_id || '')) ? _id : undefined),
[_id]
);
const [treeOpen, setTreeOpen] = useState(false); const [treeOpen, setTreeOpen] = useState(false);
@ -23,6 +28,7 @@ export default function Stock() {
instanceQuery instanceQuery
} = useInstance({ } = useInstance({
endpoint: ApiPaths.stock_location_list, endpoint: ApiPaths.stock_location_list,
hasPrimaryKey: true,
pk: id, pk: id,
params: { params: {
path_detail: true path_detail: true

View File

@ -119,12 +119,12 @@ export const routes = (
<Route path="user/*" element={<UserSettings />} /> <Route path="user/*" element={<UserSettings />} />
</Route> </Route>
<Route path="part/"> <Route path="part/">
<Route index element={<Navigate to="category/" />} /> <Route index element={<Navigate to="category/index/" />} />
<Route path="category/:id?/*" element={<CategoryDetail />} /> <Route path="category/:id?/*" element={<CategoryDetail />} />
<Route path=":id/*" element={<PartDetail />} /> <Route path=":id/*" element={<PartDetail />} />
</Route> </Route>
<Route path="stock/"> <Route path="stock/">
<Route index element={<Navigate to="location/" />} /> <Route index element={<Navigate to="location/index/" />} />
<Route path="location/:id?/*" element={<LocationDetail />} /> <Route path="location/:id?/*" element={<LocationDetail />} />
<Route path="item/:id/*" element={<StockDetail />} /> <Route path="item/:id/*" element={<StockDetail />} />
</Route> </Route>