|
1
|
import { HttpTypes } from "@medusajs/types" |
|
2
|
import { UIMatch } from "react-router-dom" |
|
3
|
import { useRegion } from "../../../hooks/api/regions" |
|
4
|
import { REGION_DETAIL_FIELDS } from "./constants" |
|
5
|
|
|
6
|
type RegionDetailBreadcrumbProps = UIMatch<HttpTypes.AdminRegionResponse> |
|
7
|
|
|
8
|
export const RegionDetailBreadcrumb = (props: RegionDetailBreadcrumbProps) => { |
|
9
|
const { id } = props.params || {} |
|
10
|
|
|
11
|
const { region } = useRegion( |
|
12
|
id!, |
|
13
|
{ |
|
14
|
fields: REGION_DETAIL_FIELDS, |
|
15
|
}, |
|
16
|
{ |
|
17
|
initialData: props.loaderData, |
|
18
|
enabled: Boolean(id), |
|
19
|
} |
|
20
|
) |
|
21
|
|
|
22
|
if (!region) { |
|
23
|
return null |
|
24
|
} |
|
25
|
|
|
26
|
return <span>{region.name}</span> |
|
27
|
} |
|
28
|
|
|
29
|
export const seo = (match: UIMatch<HttpTypes.AdminRegionResponse>) => ({ |
|
30
|
title: match.loaderData?.region?.name, |
|
31
|
}) |