Raw
1 import { HttpTypes } from "@medusajs/types"
2 import { UIMatch } from "react-router-dom"
3
4 import { useStockLocation } from "../../../hooks/api/stock-locations"
5 import { LOCATION_DETAILS_FIELD } from "./constants"
6
7 type LocationDetailBreadcrumbProps =
8 UIMatch<HttpTypes.AdminStockLocationResponse>
9
10 export const LocationDetailBreadcrumb = (
11 props: LocationDetailBreadcrumbProps
12 ) => {
13 const { location_id } = props.params || {}
14
15 const { stock_location } = useStockLocation(
16 location_id!,
17 {
18 fields: LOCATION_DETAILS_FIELD,
19 },
20 {
21 initialData: props.loaderData,
22 enabled: Boolean(location_id),
23 }
24 )
25
26 if (!stock_location) {
27 return null
28 }
29
30 return <span>{stock_location.name}</span>
31 }
32
33 export const seo = (match: UIMatch<HttpTypes.AdminStockLocationResponse>) => ({
34 title: match.loaderData?.stock_location?.name,
35 })