|
1
|
import { HttpTypes } from "@medusajs/types" |
|
2
|
import { UIMatch } from "react-router-dom" |
|
3
|
|
|
4
|
import { useInventoryItem } from "../../../hooks/api" |
|
5
|
import { INVENTORY_DETAIL_FIELDS } from "./constants" |
|
6
|
|
|
7
|
type InventoryDetailBreadcrumbProps = |
|
8
|
UIMatch<HttpTypes.AdminInventoryItemResponse> |
|
9
|
|
|
10
|
export const InventoryDetailBreadcrumb = ( |
|
11
|
props: InventoryDetailBreadcrumbProps |
|
12
|
) => { |
|
13
|
const { id } = props.params || {} |
|
14
|
|
|
15
|
const { inventory_item } = useInventoryItem( |
|
16
|
id!, |
|
17
|
{ |
|
18
|
fields: INVENTORY_DETAIL_FIELDS, |
|
19
|
}, |
|
20
|
{ |
|
21
|
initialData: props.loaderData, |
|
22
|
enabled: Boolean(id), |
|
23
|
} |
|
24
|
) |
|
25
|
|
|
26
|
if (!inventory_item) { |
|
27
|
return null |
|
28
|
} |
|
29
|
|
|
30
|
return <span>{inventory_item.title ?? inventory_item.sku ?? id}</span> |
|
31
|
} |
|
32
|
|
|
33
|
export const seo = (match: UIMatch<HttpTypes.AdminInventoryItemResponse>) => { |
|
34
|
const item = match.loaderData?.inventory_item |
|
35
|
|
|
36
|
return { |
|
37
|
title: item ? item.title ?? item.sku ?? match.params.id : undefined, |
|
38
|
} |
|
39
|
} |