Splatte
Splatte
TTCTheo's Typesafe Cult
Created by Splatte on 7/12/2023 in #questions
Fetching real time data in Next 13 on the client side
<form
action={createGuestBookEntry}
className="mb-5 flex flex-col gap-2 max-w-[500px] text-sm"
>
<input
type="text"
name="entry"
placeholder="Your message..."
required
className="pl-4 pr-32 py-2 border rounded bg-transparent text-white"
/>
<div className="flex gap-2 justify-start">
<button
type="submit"
className="text-white border p-2 rounded"
>
Sign Guestbook
</button>
<a className="text-white border p-2 rounded">
<SignOutButton>Sign Out</SignOutButton>
</a>
</div>
</form>
<form
action={createGuestBookEntry}
className="mb-5 flex flex-col gap-2 max-w-[500px] text-sm"
>
<input
type="text"
name="entry"
placeholder="Your message..."
required
className="pl-4 pr-32 py-2 border rounded bg-transparent text-white"
/>
<div className="flex gap-2 justify-start">
<button
type="submit"
className="text-white border p-2 rounded"
>
Sign Guestbook
</button>
<a className="text-white border p-2 rounded">
<SignOutButton>Sign Out</SignOutButton>
</a>
</div>
</form>
4 replies
TTCTheo's Typesafe Cult
Created by Splatte on 7/12/2023 in #questions
Fetching real time data in Next 13 on the client side
function getEntries() {
return prisma.guestbook.findMany({
take: 100,
});
}

async function createGuestBookEntry(data: FormData) {
"use server";
const user = await currentUser();

const entry = data.get("entry")?.valueOf();

if (!entry || typeof entry !== "string" || entry.length === 0) {
throw new Error("Invalid entry");
}

await prisma.guestbook.create({
data: {
content: entry,
name: user?.firstName + " " + user?.lastName,
},
});
}
function getEntries() {
return prisma.guestbook.findMany({
take: 100,
});
}

async function createGuestBookEntry(data: FormData) {
"use server";
const user = await currentUser();

const entry = data.get("entry")?.valueOf();

if (!entry || typeof entry !== "string" || entry.length === 0) {
throw new Error("Invalid entry");
}

await prisma.guestbook.create({
data: {
content: entry,
name: user?.firstName + " " + user?.lastName,
},
});
}
4 replies
TTCTheo's Typesafe Cult
Created by Splatte on 7/6/2023 in #questions
Both my dev environment and my deployed code are the exact same, but my text is aligned differently
Bingo, thank you bro
8 replies