feat: add test page with buttons for logging and server mutation
This commit is contained in:
parent
1860bce2a3
commit
467933299e
2 changed files with 48 additions and 1 deletions
37
apps/infoalloggi/src/pages/test.tsx
Normal file
37
apps/infoalloggi/src/pages/test.tsx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import type { NextPage } from "next";
|
||||
import { Button } from "~/components/ui/button";
|
||||
import { api } from "~/utils/api";
|
||||
|
||||
const Test: NextPage = () => {
|
||||
const { mutate } = api.test.testErr.useMutation();
|
||||
return (
|
||||
<div className="flex gap-4 p-4">
|
||||
<Button onClick={() => console.log("test console.log")} type="button">
|
||||
test console.log
|
||||
</Button>
|
||||
<Button onClick={() => console.info("test console.info")} type="button">
|
||||
test console.info
|
||||
</Button>
|
||||
<Button onClick={() => console.error("test console.error")} type="button">
|
||||
test console.error
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
throw new Error("test Error");
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
test Error
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
mutate();
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
Server
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default Test;
|
||||
|
|
@ -1,9 +1,19 @@
|
|||
import { createTRPCRouter, protectedApiProcedure } from "~/server/api/trpc";
|
||||
import {
|
||||
createTRPCRouter,
|
||||
protectedApiProcedure,
|
||||
publicProcedure,
|
||||
} from "~/server/api/trpc";
|
||||
|
||||
export const testRouter = createTRPCRouter({
|
||||
testApi: protectedApiProcedure.query(async () => {
|
||||
return "Hello World!";
|
||||
}),
|
||||
testErr: publicProcedure.mutation(async () => {
|
||||
console.log("test console.log");
|
||||
console.info("test console.info");
|
||||
console.error("test console.error");
|
||||
throw new Error("This is a test error");
|
||||
}),
|
||||
|
||||
/*
|
||||
PROTECTED API CALL EXAMPLE
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue