add prefetch to table
This commit is contained in:
parent
3e9cd90f5f
commit
95756e5b37
@ -4,17 +4,6 @@ import { appRouter } from "~/server/api/root";
|
|||||||
import { prisma } from "~/server/db";
|
import { prisma } from "~/server/db";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const ResourceViewPage = (props: InferGetStaticPropsType<typeof getStaticProps>) => {
|
|
||||||
const { id } = props;
|
|
||||||
const resourceQuery = api.auditoryResource.byId.useQuery({ id });
|
|
||||||
|
|
||||||
return <>
|
|
||||||
<div>
|
|
||||||
{resourceQuery.data?.name ?? 'loading..'}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getStaticPaths = async () => {
|
export const getStaticPaths = async () => {
|
||||||
//const amountPerPage = 10;
|
//const amountPerPage = 10;
|
||||||
const resources = (await prisma.auditoryResource.findMany({
|
const resources = (await prisma.auditoryResource.findMany({
|
||||||
@ -57,4 +46,15 @@ export async function getStaticProps(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ResourceViewPage = (props: InferGetStaticPropsType<typeof getStaticProps>) => {
|
||||||
|
const { id } = props;
|
||||||
|
const resourceQuery = api.auditoryResource.byId.useQuery({ id });
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<div>
|
||||||
|
{resourceQuery.data?.name ?? 'loading..'}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
};
|
||||||
|
|
||||||
export default ResourceViewPage
|
export default ResourceViewPage
|
@ -1,8 +1,29 @@
|
|||||||
|
import { createProxySSGHelpers } from "@trpc/react-query/ssg";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import ResourceTable from "~/components/ResourceTable";
|
import ResourceTable from "~/components/ResourceTable";
|
||||||
|
import { appRouter } from "~/server/api/root";
|
||||||
|
import { prisma } from "~/server/db";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
|
export async function getStaticProps() {
|
||||||
|
const ssg = createProxySSGHelpers({
|
||||||
|
router: appRouter,
|
||||||
|
ctx: {
|
||||||
|
prisma,
|
||||||
|
session: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await ssg.auditoryResource.getAll.prefetch();
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: ssg.dehydrate(),
|
||||||
|
},
|
||||||
|
revalidate: 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const Resources = () => {
|
const Resources = () => {
|
||||||
const query = api.auditoryResource.getAll.useQuery();
|
const query = api.auditoryResource.getAll.useQuery();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user