From 863906de868a3ef928741be1273ec0620ec17b8d Mon Sep 17 00:00:00 2001 From: Leon van Zyl Date: Wed, 13 Aug 2025 11:37:24 +0200 Subject: [PATCH] ui/ reusable header --- src/app/chat/page.tsx | 109 ++++++++++++++++----------------- src/app/dashboard/page.tsx | 43 ++++++++----- src/app/layout.tsx | 2 + src/app/page.tsx | 38 ++++++------ src/components/site-header.tsx | 20 ++++++ 5 files changed, 119 insertions(+), 93 deletions(-) create mode 100644 src/components/site-header.tsx diff --git a/src/app/chat/page.tsx b/src/app/chat/page.tsx index 7d09d67..1a7d8af 100644 --- a/src/app/chat/page.tsx +++ b/src/app/chat/page.tsx @@ -133,79 +133,76 @@ export default function ChatPage() { const [input, setInput] = useState(""); if (isPending) { - return ( -
- Loading... -
- ); + return
Loading...
; } if (!session) { return ( -
- +
+
+ +
); } return ( -
-
-

AI Chat

-
+
+
+
+

AI Chat

Welcome, {session.user.name}! -
-
-
- {messages.length === 0 && ( -
- Start a conversation with AI -
- )} - {messages.map((message) => ( -
-
- {message.role === "user" ? "You" : "AI"} +
+ {messages.length === 0 && ( +
+ Start a conversation with AI
-
{renderMessageContent(message as MaybePartsMessage)}
-
- ))} -
+ )} + {messages.map((message) => ( +
+
+ {message.role === "user" ? "You" : "AI"} +
+
{renderMessageContent(message as MaybePartsMessage)}
+
+ ))} +
-
{ - e.preventDefault(); - const text = input.trim(); - if (!text) return; - sendMessage({ role: "user", parts: [{ type: "text", text }] }); - setInput(""); - }} - className="flex gap-2" - > - setInput(e.target.value)} - placeholder="Type your message..." - className="flex-1 p-2 border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-ring" - /> - -
+ setInput(e.target.value)} + placeholder="Type your message..." + className="flex-1 p-2 border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-ring" + /> + + +
); } diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 3b24edd..1b2299c 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -1,32 +1,37 @@ -"use client" +"use client"; -import { UserProfile } from "@/components/auth/user-profile" -import { useSession } from "@/lib/auth-client" -import { Button } from "@/components/ui/button" -import Link from "next/link" +import { useSession } from "@/lib/auth-client"; +import { UserProfile } from "@/components/auth/user-profile"; +import { Button } from "@/components/ui/button"; +import Link from "next/link"; export default function DashboardPage() { - const { data: session, isPending } = useSession() + const { data: session, isPending } = useSession(); if (isPending) { - return
Loading...
+ return ( +
+ Loading... +
+ ); } if (!session) { return ( -
- +
+
+ +
- ) + ); } return (

Dashboard

-
- +

AI Chat

@@ -37,18 +42,22 @@ export default function DashboardPage() { Go to Chat
- +

Profile

Manage your account settings and preferences

-

Name: {session.user.name}

-

Email: {session.user.email}

+

+ Name: {session.user.name} +

+

+ Email: {session.user.email} +

- ) -} \ No newline at end of file + ); +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 0f2c6d3..60afe66 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,6 +1,7 @@ import type { Metadata } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import "./globals.css"; +import { SiteHeader } from "@/components/site-header"; const geistSans = Geist({ variable: "--font-geist-sans", @@ -27,6 +28,7 @@ export default function RootLayout({ + {children} diff --git a/src/app/page.tsx b/src/app/page.tsx index a52e634..04ba735 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,21 +1,9 @@ -import Link from "next/link" -import { Button } from "@/components/ui/button" -import { UserProfile } from "@/components/auth/user-profile" +import Link from "next/link"; +import { Button } from "@/components/ui/button"; export default function Home() { return (
-
-
-

- - Next.js Starter Kit - -

- -
-
-
@@ -23,7 +11,8 @@ export default function Home() { Welcome to Your Next.js Boilerplate

- A complete starter kit with authentication, database, AI integration, and modern tooling + A complete starter kit with authentication, database, AI + integration, and modern tooling

@@ -58,9 +47,12 @@ export default function Home() {

Next Steps

-

1. Set up environment variables

+

+ 1. Set up environment variables +

- Copy .env.example to .env.local and configure: + Copy .env.example to .env.local and + configure:

  • DATABASE_URL (PostgreSQL connection string)
  • @@ -84,7 +76,12 @@ export default function Home() { -
@@ -92,7 +89,8 @@ export default function Home() {

4. Start building

- Customize the components, add your own pages, and build your application on top of this solid foundation. + Customize the components, add your own pages, and build your + application on top of this solid foundation.

@@ -106,5 +104,5 @@ export default function Home() {
- ) + ); } diff --git a/src/components/site-header.tsx b/src/components/site-header.tsx new file mode 100644 index 0000000..21439d3 --- /dev/null +++ b/src/components/site-header.tsx @@ -0,0 +1,20 @@ +import Link from "next/link"; +import { UserProfile } from "@/components/auth/user-profile"; + +export function SiteHeader() { + return ( +
+
+

+ + Next.js Starter Kit + +

+ +
+
+ ); +}