-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathpage.tsx
32 lines (23 loc) · 869 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
"use client";
import type { Metadata } from "next";
import { useQuery } from "react-query";
import { Form } from "../../../../components/{{{lc}}}/Form";
import { {{{ucf}}} } from "../../../../types/{{{ucf}}}";
import { customFetch, FetchResponse } from "../../../../utils/dataAccess";
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}} } = {} } = useQuery<FetchResponse<{{{ucf}}}> | undefined>(['{{{lc}}}', id], () => get{{{ucf}}}(id));
if (!{{{lc}}}) {
return null;
}
return (
<div>
<title>{`Edit {{{ucf}}} ${ {{{lc}}}["@id"]}`}</title>
<Form {{{lc}}}={ {{{lc}}} } />
</div>
);
};