-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathpage.tsx
34 lines (25 loc) · 973 Bytes
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use client";
import { useQuery } from "react-query";
import { Show } from "../../../components/{{{lc}}}/Show";
import { {{{ucf}}} } from "../../../types/{{{ucf}}}";
import { customFetch, FetchResponse } from "../../../utils/dataAccess";
import { useMercure } from "../../../utils/mercure";
const get{{{ucf}}} = async (id: string|string[]|undefined) => id ? await customFetch<{{{ucf}}}>(`/{{{name}}}/${id}`) : Promise.resolve(undefined);
type Props = {
params: { id: string };
};
export default function Page({ params }: Props) {
const { id } = params;
const { data: { data: {{lc}}, hubURL } = { hubURL: null, text: '' } } =
useQuery<FetchResponse<{{{ucf}}}> | undefined>(['{{{lc}}}', id], () => get{{{ucf}}}(id));
const {{{lc}}}Data = useMercure({{lc}}, hubURL);
if (!{{{lc}}}Data) {
return null;
}
return (
<div>
<title>{`Show {{{ucf}}} ${ {{{lc}}}Data["@id"]}`}</title>
<Show {{{lc}}}={ {{{lc}}}Data } />
</div>
);
};