trpc demo

This commit is contained in:
2025-04-12 01:49:57 +02:00
parent 41059d9396
commit 10d1c91dea
15 changed files with 255 additions and 30 deletions

View File

@@ -0,0 +1,26 @@
'use client'
import { trpc } from "~/app/_trpc/Client"
import CvEntry, { type CvEntryProps } from "./CvEntry"
import type { servTrpc } from "~/app/_trpc/ServerClient"
type CvCategoryProps = {
initialData: Awaited<ReturnType<typeof servTrpc.cvCategory.get>>,
children?: React.ReactElement<CvEntryProps>
}
export default function CvCategory(props:CvCategoryProps) {
const cvCategories = trpc.cvCategory.get.useQuery(undefined,{
initialData: props.initialData,
refetchOnMount: false,
refetchOnReconnect: false,
});
return (
<div>
{cvCategories.data.map((cat) => {
return (
<div key={cat.id}>
{cat.name}
</div>
)
})}
</div>
)
}

View File

@@ -0,0 +1,7 @@
import type { cvEntry } from "~/server/db/schema"
export type CvEntryProps = typeof cvEntry
export default function CvEntry(cvEntry: CvEntryProps) {
return (<></>)
}

View File

@@ -0,0 +1,3 @@
export default function CvLayout({children,}: Readonly<{ children: React.ReactNode }>) {
return (<></>)
}

View File

@@ -1,18 +1,10 @@
import { getCvCategories } from "~/server/db/query"
import { servTrpc } from "~/app/_trpc/ServerClient"
import CvCategory from "./_components/CvCategory";
export default async function CvPage() {
const cvCategories = await getCvCategories();
const cvCategories = await servTrpc.cvCategory.get();
return (
<div>
{cvCategories.map((category) => {
return (
<div key={category.id}>
<div>
{category.name}
</div>
</div>
)
})}
</div>
<CvCategory initialData={cvCategories}>
<></>
</CvCategory>
)
}