-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffff032
commit 370e6ec
Showing
10 changed files
with
127 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import { fetchPosts } from "~/server/posts" | ||
import Heading from "~/components/Heading" | ||
import Nav from "~/components/Nav" | ||
import PostWizard from "~/components/PostWizard" | ||
import { currentUser } from "@clerk/nextjs" | ||
import { fetchPosts } from "~/server/post" | ||
import CreatePostWizard from "~/components/CreatePostWizard" | ||
import Footer from "~/components/Footer" | ||
import SignIn from "~/components/SignIn" | ||
|
||
export default async function Home() { | ||
const data = await fetchPosts() | ||
const entries = await fetchPosts() | ||
const user = await currentUser() | ||
return ( | ||
<> | ||
<Heading /> | ||
<PostWizard /> | ||
<div className="sticky top-0 bg-slate1/90 backdrop-blur"> | ||
<h1 className="text-3xl font-bold pt-6">Sign my guestbook</h1> | ||
<div className="mt-6 border-b border-slate6 pb-6"> | ||
{user ? <CreatePostWizard /> : <SignIn />} | ||
</div> | ||
</div> | ||
|
||
<div className="mt-6 space-y-2"> | ||
{data.map((data) => ( | ||
<p key={data.post.id}> | ||
<span className="text-slate11"> | ||
{data.author?.firstName} {data.author?.lastName}: | ||
</span>{" "} | ||
{data.post.content} | ||
{entries.map((entry) => ( | ||
<p key={entry.post.id}> | ||
<span className="text-slate11">{entry.author.firstName}:</span>{" "} | ||
{entry.post.content} | ||
</p> | ||
))} | ||
</div> | ||
<Nav /> | ||
<Footer /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { auth } from "@clerk/nextjs" | ||
import { prisma } from "~/server/db" | ||
import { Button } from "./ui/button" | ||
|
||
export default function CreatePostWizard() { | ||
async function createPost() { | ||
"use server" | ||
|
||
const { userId } = auth() | ||
|
||
if (!userId) throw new Error("User ID not found") | ||
|
||
const post = await prisma.post.create({ | ||
data: { | ||
authorId: userId, | ||
content: "testing of appDir", | ||
}, | ||
}) | ||
|
||
return post | ||
} | ||
|
||
return ( | ||
<form | ||
// eslint-disable-next-line @typescript-eslint/no-misused-promises | ||
action={createPost} | ||
className="flex items-center gap-2 rounded-md border border-slate7 bg-slate3 p-2 transition-colors hover:border-slate8 hover:bg-slate4" | ||
> | ||
<input | ||
type="text" | ||
name="message" | ||
id="message" | ||
className="flex-1 bg-transparent p-0 outline-none placeholder:text-slate11" | ||
placeholder="Your message..." | ||
/> | ||
<Button size="sm">Sign</Button> | ||
</form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { cn } from "~/lib/utils" | ||
|
||
interface ExternalLinkProps { | ||
href: string | ||
className?: string | ||
children: React.ReactNode | ||
} | ||
|
||
export default function ExternalLink({ | ||
href, | ||
className, | ||
children, | ||
}: ExternalLinkProps) { | ||
return ( | ||
<a | ||
className={cn( | ||
"underline decoration-slate7 underline-offset-2 transition-colors hover:text-slate11 hover:decoration-slate8", | ||
className, | ||
)} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
href={href} | ||
> | ||
{children} | ||
</a> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { siteConfig } from "~/config" | ||
import ExternalLink from "./ExternalLink" | ||
|
||
export default function Footer() { | ||
return ( | ||
<footer className="mt-6 flex items-center justify-center gap-2 border-t border-slate6 py-6"> | ||
<ExternalLink href={siteConfig.links.twitter}>Twitter</ExternalLink>∙ | ||
<ExternalLink href={siteConfig.links.github}>Github</ExternalLink>∙ | ||
<ExternalLink href={siteConfig.links.linkedin}>LinkedIn</ExternalLink>∙ | ||
<ExternalLink href={siteConfig.links.instagram}>Instagram</ExternalLink>∙ | ||
<ExternalLink href={siteConfig.links.mail}>Mail</ExternalLink> | ||
</footer> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Link from "next/link" | ||
import { LogIn } from "lucide-react" | ||
import { cn } from "~/lib/utils" | ||
import { buttonVariants } from "./ui/button" | ||
|
||
export default function SignIn() { | ||
return ( | ||
<Link | ||
href="/sign-in" | ||
className={cn( | ||
buttonVariants({ | ||
variant: "secondary", | ||
}), | ||
"gap-2", | ||
)} | ||
> | ||
<LogIn size={16} /> | ||
<span>Sign in with Google</span> | ||
</Link> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters