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