Skip to content

Commit 73105a8

Browse files
committed
Add clickable warehouse name to ProductInventoryPeek
1 parent 3ee9b42 commit 73105a8

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

apps/client/src/components/Product/ProductInventoryPeek.tsx

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { BasicWarehouseDto, ProductDto } from 'shared-types';
22
import useInventoryItemByProduct from '../../hooks/useInventoryItemByProduct';
3-
import { HTTPResponseError } from '../../utils';
3+
import { HTTPResponseError, Utils } from '../../utils';
44
import EntityInfoTable from '../Entity/EntityInfoTable';
55
import Loader from '../Loader';
6+
import { Link } from 'react-router-dom';
7+
import { useContext } from 'react';
8+
import { CurrentAppContext } from '../../context/CurrentAppContext';
69

710
export interface ProductInventoryPeek {
811
warehouse: BasicWarehouseDto;
@@ -11,13 +14,18 @@ export interface ProductInventoryPeek {
1114

1215
function ProductInventoryPeek({ warehouse, product }: ProductInventoryPeek) {
1316
const { inventoryItem, isLoading, error } = useInventoryItemByProduct(warehouse.id, product.id);
17+
const appContext = useContext(CurrentAppContext);
1418

1519
function isNotFoundError(error: any) {
1620
const isHttpError = error instanceof HTTPResponseError;
1721
if (!isHttpError) return false;
1822
return error?.response?.status == 404;
1923
}
2024

25+
const warehouseUrl = `${Utils.dashboardUrl(appContext)}/warehouses/view/${
26+
appContext.currentWarehouse.id
27+
}`;
28+
2129
return (
2230
<>
2331
<h2 className="mb-4 mt-8 text-2xl">Inventory details</h2>
@@ -26,7 +34,14 @@ function ProductInventoryPeek({ warehouse, product }: ProductInventoryPeek) {
2634
isError={error != undefined && !isNotFoundError(error)}
2735
>
2836
<p className="mb-4">
29-
Inventory details for <span className="font-bold">{warehouse.name}</span> warehouse:
37+
Inventory details for{' '}
38+
<Link
39+
to={warehouseUrl}
40+
className="link-primary font-bold"
41+
>
42+
{warehouse.name}
43+
</Link>{' '}
44+
warehouse:
3045
</p>
3146
<p>
3247
{inventoryItem ? (

0 commit comments

Comments
 (0)