feat(01-02): build agent portal layout, dashboard stub, and logout mechanism
- LogoutButton: client component with server action calling signOut to ?signed_out=1 - AgentLayout: defense-in-depth auth() check, header with email and sign-out button - DashboardPage: belt-and-suspenders auth() check, welcome message with agent email - HomePage: updated to Teressa Copeland Homes placeholder (Phase 2 marketing site) - npm run build and npx tsc --noEmit both pass with zero errors
This commit is contained in:
17
teressa-copeland-homes/src/app/agent/dashboard/page.tsx
Normal file
17
teressa-copeland-homes/src/app/agent/dashboard/page.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function DashboardPage() {
|
||||
// Defense-in-depth session check (layout also checks, this is belt-and-suspenders)
|
||||
const session = await auth();
|
||||
if (!session) redirect("/agent/login");
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold text-gray-900">Dashboard</h1>
|
||||
<p className="mt-2 text-gray-500">
|
||||
Welcome back, {session.user?.email}. Portal content coming in Phase 3.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
26
teressa-copeland-homes/src/app/agent/layout.tsx
Normal file
26
teressa-copeland-homes/src/app/agent/layout.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { LogoutButton } from "@/components/ui/LogoutButton";
|
||||
|
||||
export default async function AgentLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
// Defense-in-depth: middleware handles most cases, this catches edge cases
|
||||
const session = await auth();
|
||||
if (!session) redirect("/agent/login");
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50">
|
||||
<header className="bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between">
|
||||
<span className="text-sm font-medium text-gray-700">Agent Portal</span>
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-sm text-gray-500">{session.user?.email}</span>
|
||||
<LogoutButton />
|
||||
</div>
|
||||
</header>
|
||||
<main className="p-6">{children}</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,65 +1,11 @@
|
||||
import Image from "next/image";
|
||||
|
||||
export default function Home() {
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
|
||||
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={100}
|
||||
height={20}
|
||||
priority
|
||||
/>
|
||||
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
|
||||
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
|
||||
To get started, edit the page.tsx file.
|
||||
</h1>
|
||||
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
||||
Looking for a starting point or more instructions? Head over to{" "}
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Templates
|
||||
</a>{" "}
|
||||
or the{" "}
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Learning
|
||||
</a>{" "}
|
||||
center.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Deploy Now
|
||||
</a>
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
<main className="min-h-screen flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<h1 className="text-4xl font-bold text-gray-900">Teressa Copeland Homes</h1>
|
||||
<p className="mt-4 text-gray-600">Real estate expertise for Utah home buyers and sellers.</p>
|
||||
<p className="mt-2 text-sm text-gray-400">Marketing site coming in Phase 2.</p>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
19
teressa-copeland-homes/src/components/ui/LogoutButton.tsx
Normal file
19
teressa-copeland-homes/src/components/ui/LogoutButton.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { signOut } from "@/lib/auth";
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
await signOut({ redirectTo: "/agent/login?signed_out=1" });
|
||||
}
|
||||
|
||||
export function LogoutButton() {
|
||||
return (
|
||||
<form action={logoutAction}>
|
||||
<button
|
||||
type="submit"
|
||||
className="text-sm text-gray-600 hover:text-gray-900 underline"
|
||||
>
|
||||
Sign out
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user