From 71ab356168df4c24a3283061d60633cc092d496d Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 13 Jul 2024 00:00:51 -0600 Subject: [PATCH] refactor: update --- t3/src/app/_components/post.tsx | 80 +++++++++++++++--------------- t3/src/app/page.tsx | 86 ++++++++++++++++----------------- 2 files changed, 83 insertions(+), 83 deletions(-) diff --git a/t3/src/app/_components/post.tsx b/t3/src/app/_components/post.tsx index b6b5cb4..013e7bb 100644 --- a/t3/src/app/_components/post.tsx +++ b/t3/src/app/_components/post.tsx @@ -5,46 +5,46 @@ import { useState } from "react"; import { api } from "@/trpc/react"; export function LatestPost() { - const [latestPost] = api.post.getLatest.useSuspenseQuery(); + const [latestPost] = api.post.getLatest.useSuspenseQuery(); - const utils = api.useUtils(); - const [name, setName] = useState(""); - const createPost = api.post.create.useMutation({ - onSuccess: async () => { - await utils.post.invalidate(); - setName(""); - }, - }); + const utils = api.useUtils(); + const [name, setName] = useState(""); + const createPost = api.post.create.useMutation({ + onSuccess: async () => { + await utils.post.invalidate(); + setName(""); + }, + }); - return ( -
- {latestPost ? ( -

Your most recent post: {latestPost.name}

- ) : ( -

You have no posts yet.

- )} -
{ - e.preventDefault(); - createPost.mutate({ name }); - }} - className="flex flex-col gap-2" - > - setName(e.target.value)} - className="w-full rounded-full px-4 py-2 text-black" - /> - -
-
- ); + return ( +
+ {latestPost ? ( +

Your most recent post: {latestPost.name}

+ ) : ( +

You have no posts yet.

+ )} +
{ + e.preventDefault(); + createPost.mutate({ name }); + }} + className="flex flex-col gap-2" + > + setName(e.target.value)} + className="w-full rounded-full px-4 py-2 text-black" + /> + +
+
+ ); } diff --git a/t3/src/app/page.tsx b/t3/src/app/page.tsx index d473a0d..efc0e83 100644 --- a/t3/src/app/page.tsx +++ b/t3/src/app/page.tsx @@ -4,50 +4,50 @@ import { LatestPost } from "@/app/_components/post"; import { api, HydrateClient } from "@/trpc/server"; export default async function Home() { - const hello = await api.post.hello({ text: "from tRPC" }); + const hello = await api.post.hello({ text: "from tRPC" }); - void api.post.getLatest.prefetch(); + // void api.post.getLatest.prefetch(); - return ( - -
-
-

- Create T3 App -

-
- -

First Steps →

-
- Just the basics - Everything you need to know to set up your - database and authentication. -
- - -

Documentation →

-
- Learn more about Create T3 App, the libraries it uses, and how - to deploy it. -
- -
-
-

- {hello ? hello.greeting : "Loading tRPC query..."} -

-
+ return ( + +
+
+

+ Create T3 App +

+
+ +

First Steps →

+
+ Just the basics - Everything you need to know to set up your + database and authentication. +
+ + +

Documentation →

+
+ Learn more about Create T3 App, the libraries it uses, and how + to deploy it. +
+ +
+
+

+ {hello ? hello.greeting : "Loading tRPC query..."} +

+
- -
-
-
- ); + +
+
+
+ ); }