diff --git a/app/auth/sign-in/page.tsx b/app/auth/sign-in/page.tsx index a514102e..40c8c594 100644 --- a/app/auth/sign-in/page.tsx +++ b/app/auth/sign-in/page.tsx @@ -1,51 +1,13 @@ -// app/auth/sign-in/page.tsx -import { Suspense } from "react"; -import type { Metadata } from "next"; -import Link from "next/link"; - -// UI (shadcn) -import { Input } from "@/components/ui/input"; -import { Button } from "@/components/ui/button"; - -export const metadata: Metadata = { title: "Sign in" }; - -// Server Component wrapper — no hooks here -export default function SignInPage() { - return ( -
-
-
-

Sign in

-

- Welcome back. Enter your credentials to continue. -

-
- - {/* Client sub-component wrapped in Suspense so useSearchParams is allowed */} - Loading…
}> - - - -

- Don’t have an account?{" "} - - Create one - -

-
- - ); -} - -// ───────────────────────────────────────────────────────────── -// Client piece that actually uses useSearchParams/router/fetch -// ───────────────────────────────────────────────────────────── "use client"; +import Link from "next/link"; import { useRouter, useSearchParams } from "next/navigation"; import { useState } from "react"; -function SignInClient() { +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; + +export default function SignInPage() { const router = useRouter(); const sp = useSearchParams(); @@ -61,8 +23,6 @@ function SignInClient() { setErr(null); setSubmitting(true); try { - // Post both a generic "identity" and the same value under email/username - // so the API route can accept any of them. const res = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, @@ -76,7 +36,6 @@ function SignInClient() { const data = await res.json().catch(() => ({})); if (!res.ok) throw new Error(data?.error || "Login failed"); - // Cookies (httpOnly) were set server-side; client just navigates. router.replace(next); } catch (e: any) { setErr(e?.message || "Login failed"); @@ -86,12 +45,22 @@ function SignInClient() { } return ( +
+
+
+

Sign in

+

+ Welcome back. Enter your credentials to continue. +

+
+
{err && (
{err}
)} +
+
- {/* keep the next param visible to the client sub-component */} + +

+ Don’t have an account?{" "} + + Create one + +

+
+
); } diff --git a/app/auth/sign-up/page.tsx b/app/auth/sign-up/page.tsx index da6b8a5a..3bd287aa 100644 --- a/app/auth/sign-up/page.tsx +++ b/app/auth/sign-up/page.tsx @@ -1,46 +1,13 @@ -// app/auth/sign-up/page.tsx -import { Suspense } from "react"; -import type { Metadata } from "next"; -import Link from "next/link"; - -// UI (shadcn) -import { Input } from "@/components/ui/input"; -import { Button } from "@/components/ui/button"; - -export const metadata: Metadata = { title: "Create account" }; - -export default function SignUpPage() { - return ( -
-
-
-

Create account

-

- Pick a username and password. Email is optional (recommended for password reset). -

-
- - Loading…
}> - - - -

- Already have an account?{" "} - - Sign in - -

-
-
- ); -} - "use client"; +import Link from "next/link"; import { useRouter, useSearchParams } from "next/navigation"; import { useState } from "react"; -function SignUpClient() { +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; + +export default function SignUpPage() { const router = useRouter(); const sp = useSearchParams(); @@ -69,7 +36,6 @@ function SignUpClient() { const data = await res.json().catch(() => ({})); if (!res.ok) throw new Error(data?.error || "Registration failed"); - // Registration API should already log user in (sets cookies), then redirect router.replace(next); } catch (e: any) { setErr(e?.message || "Registration failed"); @@ -79,6 +45,15 @@ function SignUpClient() { } return ( +
+
+
+

Create account

+

+ Pick a username and password. Email is optional (recommended for password reset). +

+
+
{err && (
@@ -130,5 +105,14 @@ function SignUpClient() { + +

+ Already have an account?{" "} + + Sign in + +

+
+
); }