|
1
|
import { HttpTypes } from "@medusajs/types" |
|
2
|
import { UIMatch } from "react-router-dom" |
|
3
|
|
|
4
|
import { useTaxRegion } from "../../../hooks/api" |
|
5
|
import { getCountryByIso2 } from "../../../lib/data/countries" |
|
6
|
|
|
7
|
type TaxRegionDetailBreadcrumbProps = UIMatch<HttpTypes.AdminTaxRegionResponse> |
|
8
|
|
|
9
|
export const TaxRegionDetailBreadcrumb = ( |
|
10
|
props: TaxRegionDetailBreadcrumbProps |
|
11
|
) => { |
|
12
|
const { id } = props.params || {} |
|
13
|
|
|
14
|
const { tax_region } = useTaxRegion(id!, undefined, { |
|
15
|
initialData: props.loaderData, |
|
16
|
enabled: Boolean(id), |
|
17
|
}) |
|
18
|
|
|
19
|
if (!tax_region) { |
|
20
|
return null |
|
21
|
} |
|
22
|
|
|
23
|
return ( |
|
24
|
<span> |
|
25
|
{getCountryByIso2(tax_region.country_code)?.display_name || |
|
26
|
tax_region.country_code?.toUpperCase()} |
|
27
|
</span> |
|
28
|
) |
|
29
|
} |
|
30
|
|
|
31
|
export const seo = (match: UIMatch<HttpTypes.AdminTaxRegionResponse>) => { |
|
32
|
const taxRegion = match.loaderData?.tax_region |
|
33
|
|
|
34
|
return { |
|
35
|
title: taxRegion |
|
36
|
? getCountryByIso2(taxRegion.country_code)?.display_name || |
|
37
|
taxRegion.country_code?.toUpperCase() |
|
38
|
: undefined, |
|
39
|
} |
|
40
|
} |