feat: add Magic Hotel style index and register pages
This commit is contained in:
1 parent
964c8b5f5a
commit
87bda8dbef
2 files changed
+41
-68
No files matched your search
+11
-33
@@ -1,34 +1,12 @@
|
||||
import GuestView from "@/components/home/guest-view";
|
||||
import UserView from "@/components/home/user-view";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function HomePage() {
|
||||
const session = await auth();
|
||||
|
||||
if (!session?.user) {
|
||||
return <GuestView />;
|
||||
}
|
||||
|
||||
const dbUser = await prisma.user
|
||||
.findUnique({
|
||||
where: { id: Number(session.user.id) },
|
||||
select: { username: true, look: true, motto: true },
|
||||
})
|
||||
.catch(() => null);
|
||||
|
||||
if (!dbUser) {
|
||||
return <p className="py-8 text-center text-gray-500">User not found.</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
<UserView
|
||||
userId={Number(session.user.id)}
|
||||
username={dbUser.username}
|
||||
look={dbUser.look}
|
||||
motto={dbUser.motto}
|
||||
/>
|
||||
);
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-gray-100 p-4">
|
||||
<div className="max-w-md w-full bg-white p-8 rounded-lg shadow-lg text-center">
|
||||
<h1 className="text-2xl font-bold mb-2">Magic Hotel</h1>
|
||||
<p className="mb-6">0ONLINE</p>
|
||||
<a href="/login" className="inline-block bg-blue-600 text-white py-2 px-4 rounded hover:bg-blue-700 mr-2">Login</a>
|
||||
<a href="/register" className="inline-block bg-green-600 text-white py-2 px-4 rounded hover:bg-green-700">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,36 +1,31 @@
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { headers } from "next/headers";
|
||||
import { RegisterForm } from "@/components/auth/register-form";
|
||||
import { captchaConfig } from "@/lib/services/captcha";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
export const revalidate = 300;
|
||||
|
||||
export default async function RegisterPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ error?: string }>;
|
||||
}) {
|
||||
const t = await getTranslations("pages.register");
|
||||
const { error } = await searchParams;
|
||||
const nonce = (await headers()).get("x-nonce") ?? undefined;
|
||||
|
||||
const [hotelName, captcha] = await Promise.all([
|
||||
siteSettings.get("hotel_name", "Atom"),
|
||||
captchaConfig(),
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className="flex min-h-[calc(100vh-200px)] items-center justify-center px-4 py-8">
|
||||
<div className="w-full">
|
||||
<h1 className="sr-only">{t("title")}</h1>
|
||||
<RegisterForm
|
||||
hotelName={hotelName ?? "Atom"}
|
||||
captcha={captcha}
|
||||
error={error}
|
||||
nonce={nonce}
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
export default function Register() {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-gray-100 p-4">
|
||||
<div className="max-w-md w-full bg-white p-8 rounded-lg shadow-lg text-center">
|
||||
<h1 className="text-2xl font-bold mb-4">Konto erstellen</h1>
|
||||
<form className="space-y-4 mb-8">
|
||||
<div>
|
||||
<label className="block text-sm font-medium">Benutzername</label>
|
||||
<input type="text" name="username" className="mt-1 w-full px-3 py-2 border rounded focus:ring-blue-500" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium">E‑Mail</label>
|
||||
<input type="email" name="email" className="mt-1 w-full px-3 py-2 border rounded focus:ring-blue-500" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium">Passwoord</label>
|
||||
<input type="password" name="password" className="mt-1 w-full px-3 py-2 border rounded focus:ring-blue-500" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium">Passwoord opnieuw</label>
|
||||
<input type="password" name="confirmPassword" className="mt-1 w-full px-3 py-2 border rounded focus:ring-blue-500" />
|
||||
</div>
|
||||
</form>
|
||||
<button type="submit" className="w-full bg-green-600 text-white py-2 rounded hover:bg-green-700">Konto erstellen</button>
|
||||
<p className="mt-4">
|
||||
<a href="/" className="text-blue-600 hover:underline">Al een account? Inloggen</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user