From 8eec2f32c019e6b98faabed566cb21a07ed99998 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 16 Jan 2024 22:12:28 +1100 Subject: [PATCH] Panel index fix (#6255) * Fix panel routing for part category index * Fix routing for stock location index --- src/frontend/src/pages/part/CategoryDetail.tsx | 7 ++++++- src/frontend/src/pages/stock/LocationDetail.tsx | 8 +++++++- src/frontend/src/router.tsx | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/pages/part/CategoryDetail.tsx b/src/frontend/src/pages/part/CategoryDetail.tsx index 30f63b6ba4..6a8e07d011 100644 --- a/src/frontend/src/pages/part/CategoryDetail.tsx +++ b/src/frontend/src/pages/part/CategoryDetail.tsx @@ -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 */ 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); @@ -33,6 +37,7 @@ export default function CategoryDetail({}: {}) { instanceQuery } = useInstance({ endpoint: ApiPaths.category_list, + hasPrimaryKey: true, pk: id, params: { path_detail: true diff --git a/src/frontend/src/pages/stock/LocationDetail.tsx b/src/frontend/src/pages/stock/LocationDetail.tsx index af55680e8a..8a40a57a06 100644 --- a/src/frontend/src/pages/stock/LocationDetail.tsx +++ b/src/frontend/src/pages/stock/LocationDetail.tsx @@ -13,7 +13,12 @@ import { ApiPaths } from '../../enums/ApiEndpoints'; import { useInstance } from '../../hooks/UseInstance'; 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); @@ -23,6 +28,7 @@ export default function Stock() { instanceQuery } = useInstance({ endpoint: ApiPaths.stock_location_list, + hasPrimaryKey: true, pk: id, params: { path_detail: true diff --git a/src/frontend/src/router.tsx b/src/frontend/src/router.tsx index 45713dbe38..dd82991751 100644 --- a/src/frontend/src/router.tsx +++ b/src/frontend/src/router.tsx @@ -119,12 +119,12 @@ export const routes = ( } /> - } /> + } /> } /> } /> - } /> + } /> } /> } />