import { GetServerSideProps, NextComponentType, NextPageContext } from "next"; import Head from "next/head"; import { dehydrate, QueryClient, useQuery } from "react-query"; import Pagination from "../../components/common/Pagination"; import { List } from "../../components/{{{lc}}}/List"; import { PagedCollection } from "../../types/collection"; import { {{{ucf}}} } from "../../types/{{{ucf}}}"; import { fetch, FetchResponse } from "../../utils/dataAccess"; import { useMercure } from "../../utils/mercure"; const get{{{ucf}}}s = async () => await fetch>('/{{{name}}}'); const Page: NextComponentType = () => { const { data: { data: {{lc}}s, hubURL } = { hubURL: null } } = useQuery> | undefined>('{{{name}}}', get{{{ucf}}}s); const collection = useMercure({{lc}}s, hubURL); if (!collection || !collection["{{{hydraPrefix}}}member"]) return null; return (
{{{ucf}}} List
); }; export const getServerSideProps: GetServerSideProps = async () => { const queryClient = new QueryClient(); await queryClient.prefetchQuery('{{{name}}}', get{{{ucf}}}s); return { props: { dehydratedState: dehydrate(queryClient), }, }; } export default Page;