1
1
import { BasicWarehouseDto , ProductDto } from 'shared-types' ;
2
2
import useInventoryItemByProduct from '../../hooks/useInventoryItemByProduct' ;
3
- import { HTTPResponseError } from '../../utils' ;
3
+ import { HTTPResponseError , Utils } from '../../utils' ;
4
4
import EntityInfoTable from '../Entity/EntityInfoTable' ;
5
5
import Loader from '../Loader' ;
6
+ import { Link } from 'react-router-dom' ;
7
+ import { useContext } from 'react' ;
8
+ import { CurrentAppContext } from '../../context/CurrentAppContext' ;
6
9
7
10
export interface ProductInventoryPeek {
8
11
warehouse : BasicWarehouseDto ;
@@ -11,13 +14,18 @@ export interface ProductInventoryPeek {
11
14
12
15
function ProductInventoryPeek ( { warehouse, product } : ProductInventoryPeek ) {
13
16
const { inventoryItem, isLoading, error } = useInventoryItemByProduct ( warehouse . id , product . id ) ;
17
+ const appContext = useContext ( CurrentAppContext ) ;
14
18
15
19
function isNotFoundError ( error : any ) {
16
20
const isHttpError = error instanceof HTTPResponseError ;
17
21
if ( ! isHttpError ) return false ;
18
22
return error ?. response ?. status == 404 ;
19
23
}
20
24
25
+ const warehouseUrl = `${ Utils . dashboardUrl ( appContext ) } /warehouses/view/${
26
+ appContext . currentWarehouse . id
27
+ } `;
28
+
21
29
return (
22
30
< >
23
31
< h2 className = "mb-4 mt-8 text-2xl" > Inventory details</ h2 >
@@ -26,7 +34,14 @@ function ProductInventoryPeek({ warehouse, product }: ProductInventoryPeek) {
26
34
isError = { error != undefined && ! isNotFoundError ( error ) }
27
35
>
28
36
< 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:
30
45
</ p >
31
46
< p >
32
47
{ inventoryItem ? (
0 commit comments