1 import { HttpTypes } from "@medusajs/types"
2 import { UIMatch } from "react-router-dom"
3
4 import { useCustomer } from "../../../hooks/api"
5
6 type CustomerDetailBreadcrumbProps = UIMatch<HttpTypes.AdminCustomerResponse>
7
8 export const CustomerDetailBreadcrumb = (
9 props: CustomerDetailBreadcrumbProps
10 ) => {
11 const { id } = props.params || {}
12
13 const { customer } = useCustomer(id!, undefined, {
14 initialData: props.loaderData,
15 enabled: Boolean(id),
16 })
17
18 if (!customer) {
19 return null
20 }
21
22 const name = [customer.first_name, customer.last_name]
23 .filter(Boolean)
24 .join(" ")
25
26 const display = name || customer.email
27
28 return <span>{display}</span>
29 }
30
31 export const seo = (match: UIMatch<HttpTypes.AdminCustomerResponse>) => {
32 const customer = match.loaderData?.customer
33
34 if (!customer) {
35 return { title: undefined }
36 }
37
38 const name = [customer.first_name, customer.last_name]
39 .filter(Boolean)
40 .join(" ")
41
42 return { title: name || customer.email }
43 }