import { useShow, useOne } from "@pankod/refine-core";
import { Show, Title, Text, TextField } from "@pankod/refine-mantine";
const PostShow: React.FC<IResourceComponentsProps> = () => {
const { queryResult } = useShow<IPost>();
const { data, isLoading } = queryResult;
const record = data?.data;
const { data: categoryData, isLoading: categoryIsLoading } =
useOne<ICategory>({
resource: "categories",
id: record?.category?.id,
queryOptions: {
enabled: !!record,
},
});
return (
<Show isLoading={isLoading}>
<Title order={5}>Id</Title>
<Text mt="sm">{record?.id}</Text>
<Title mt="sm" order={5}>
Category
</Title>
<TextField
value={
categoryIsLoading ? "Loading..." : categoryData?.data?.title
}
/>
</Show>
);
};
interface ICategory {
id: number;
title: string;
}
interface IPost {
id: number;
category: { id: number };
}