Prechádzať zdrojové kódy

RHL-020 refactor(login): implement LoginPage with query parameter handling and render LoginForm

Code_Uwe 1 mesiac pred
rodič
commit
03a9fc937d
1 zmenil súbory, kde vykonal 25 pridanie a 37 odobranie
  1. 25 37
      app/(public)/login/page.jsx

+ 25 - 37
app/(public)/login/page.jsx

@@ -1,55 +1,43 @@
-import { Button } from "@/components/ui/button";
+// ---------------------------------------------------------------------------
+// Folder: app/(public)/login
+// File: page.jsx
+// Relative Path: app/(public)/login/page.jsx
+// ---------------------------------------------------------------------------
+
+import LoginForm from "@/components/auth/LoginForm";
+import { parseLoginParams } from "@/lib/frontend/authRedirect";
 
 /**
- * /login
+ * /login (RHL-020)
  *
- * RHL-019 scope:
- * - UI placeholder only
- * - No form logic, no apiClient calls, no redirects yet
+ * Server Component:
+ * - Parses query params on the server (reason/next).
+ * - Renders a Client Component (LoginForm) for the actual interaction.
  *
- * Future tickets (RHL-020/RHL-021) will implement:
- * - session checks (getMe)
- * - actual login flow
- * - redirects into the protected app
+ * Query params:
+ * - reason=expired | logged-out
+ * - next=/some/internal/path
  */
-export default function LoginPage() {
+export default async function LoginPage({ searchParams }) {
+	// In newer Next versions, searchParams can be async; awaiting is safe.
+	const resolvedSearchParams = await searchParams;
+
+	// Parse + sanitize using shared pure helper.
+	const { reason, next } = parseLoginParams(resolvedSearchParams);
+
 	return (
 		<div className="w-full space-y-6">
 			<div className="space-y-2 text-center">
 				<h1 className="text-2xl font-semibold tracking-tight">
 					RHL Lieferscheine
 				</h1>
-				<p className="text-sm text-muted-foreground">
-					Login placeholder (RHL-019 scaffold)
-				</p>
+				<p className="text-sm text-muted-foreground">Sign in to continue</p>
 			</div>
 
-			<div className="rounded-lg border bg-card p-6 text-card-foreground shadow-sm">
-				<div className="space-y-3">
-					<p className="text-sm text-muted-foreground">
-						This is a placeholder page. The real login form and session guard
-						will be implemented in a later ticket.
-					</p>
-
-					<div className="flex gap-2">
-						<Button disabled aria-disabled="true" title="Not implemented yet">
-							Sign in (TODO)
-						</Button>
-						<Button
-							variant="outline"
-							disabled
-							aria-disabled="true"
-							title="Not implemented yet"
-						>
-							Forgot password (TODO)
-						</Button>
-					</div>
-				</div>
-			</div>
+			<LoginForm reason={reason} nextPath={next} />
 
 			<p className="text-center text-xs text-muted-foreground">
-				Tip: You can already test routing by opening /, /NL01, /NL01/2025/12/31
-				etc.
+				For support, contact your administrator.
 			</p>
 		</div>
 	);