Skip to content

Commit

Permalink
trying to post
Browse files Browse the repository at this point in the history
  • Loading branch information
SameerJadav committed Jul 8, 2023
1 parent c94e48c commit 8941046
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/PostWizard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
/* eslint-disable @typescript-eslint/no-misused-promises */
"use client"

import Link from "next/link"
import { useUser } from "@clerk/nextjs"
import { LogIn } from "lucide-react"
import { cn } from "~/lib/utils"
import { createPost } from "~/server/posts"
import { Button, buttonVariants } from "./ui/button"

/* eslint-disable @typescript-eslint/no-misused-promises */

export default function PostWizard() {
const { isSignedIn } = useUser()

const handleClick = async () => {
const newPost = await createPost()
}

return (
<div className="mt-6 border-b border-slate6 pb-6">
{!isSignedIn && (
Expand All @@ -35,7 +43,9 @@ export default function PostWizard() {
className="flex-1 bg-transparent p-0 outline-none placeholder:text-slate11"
placeholder="Your message..."
/>
<Button size="sm">Sign</Button>
<Button size="sm" onClick={handleClick}>
Sign
</Button>
</div>
)}
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/server/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,14 @@ export async function fetchPosts() {
throw error
}
}

export async function createPost() {
const post = await prisma.post.create({
data: {
content: "posting content from prisma",
authorId: "user_2NYBALH9IucJkHbRHwlwYAziVr0",
},
})

return post
}

0 comments on commit 8941046

Please sign in to comment.