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
*/
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

View File

@ -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

View File

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