Raw
1 import { HttpTypes } from "@medusajs/types"
2 import { UIMatch } from "react-router-dom"
3
4 import { useRbacRole } from "../../../hooks/api/rbac-roles"
5 import { ROLE_DETAIL_FIELDS } from "./constants"
6
7 type RoleDetailBreadcrumbProps = UIMatch<HttpTypes.AdminRbacRoleResponse>
8
9 export const RoleDetailBreadcrumb = (props: RoleDetailBreadcrumbProps) => {
10 const { id } = props.params || {}
11
12 const { role } = useRbacRole(
13 id!,
14 {
15 fields: ROLE_DETAIL_FIELDS,
16 },
17 {
18 initialData: props.loaderData,
19 enabled: Boolean(id),
20 }
21 )
22
23 if (!role) {
24 return null
25 }
26
27 return <span>{role.name}</span>
28 }