Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add header #4

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions apps/nextjs/src/app/_components/auth-showcase.tsx

This file was deleted.

47 changes: 47 additions & 0 deletions apps/nextjs/src/app/_components/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Link from "next/link";

import { auth, signIn, signOut } from "@acme/auth";
import { Button } from "@acme/ui/button";

export default async function Header() {
const session = await auth();
const user = session?.user;

return (
<header className="w-full bg-primary text-primary-foreground shadow-md">
<nav className="items-left mx-auto flex p-6 shadow-lg md:justify-center lg:px-8">
<div className="space-x-4 pr-4 md:flex lg:flex-1">
<Link href="/">Home</Link>
</div>
{user ? (
<div className="flex items-center">
<p className="m-3 text-sm">Logged in as {user.name}</p>
<form>
<Button
size="lg"
formAction={async () => {
"use server";
await signOut();
}}
>
Log out
</Button>
</form>
</div>
) : (
<form className="min-[320px]:px-4 sm:px-4 md:flex md:justify-end">
<Button
size="lg"
formAction={async () => {
"use server";
await signIn();
}}
>
Sign in
</Button>
</form>
)}
</nav>
</header>
);
}
9 changes: 6 additions & 3 deletions apps/nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ import { TRPCReactProvider } from "~/trpc/react";
import "~/app/globals.css";

import { env } from "~/env";
import Header from "./_components/header";

const PRODUCTION_DOMAINE =
const PRODUCTION_DOMAIN =
"https://shared-expensesnext-js-gnrsns-projects.vercel.app";

export const metadata: Metadata = {
metadataBase: new URL(
env.VERCEL_ENV === "production"
? PRODUCTION_DOMAINE
? PRODUCTION_DOMAIN
: "http://localhost:3000",
),
title: "Shared expenses",
description: "",
openGraph: {
title: "Shared expenses",
description: "",
url: PRODUCTION_DOMAINE,
url: PRODUCTION_DOMAIN,
siteName: "Shared expenses",
},
};
Expand All @@ -49,6 +50,8 @@ export default function RootLayout(props: { children: React.ReactNode }) {
)}
>
<ThemeProvider attribute="class" defaultTheme="light" enableSystem>
<Header />

<TRPCReactProvider>{props.children}</TRPCReactProvider>
<div className="absolute bottom-4 right-4">
<ThemeToggle />
Expand Down
2 changes: 0 additions & 2 deletions apps/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Suspense } from "react";

import { api } from "~/trpc/server";
import { AuthShowcase } from "./_components/auth-showcase";
import {
CreatePostForm,
PostCardSkeleton,
Expand All @@ -20,7 +19,6 @@ export default function HomePage() {
<h1 className="text-5xl font-extrabold tracking-tight sm:text-[5rem]">
<span className="text-primary">Shared</span> Expenses
</h1>
<AuthShowcase />

<CreatePostForm />
<div className="w-full max-w-2xl overflow-y-scroll">
Expand Down
Loading