latest changes
This commit is contained in:
+27
-48
@@ -1,8 +1,6 @@
|
||||
import Script from "next/script";
|
||||
import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { register } from "@/actions/register";
|
||||
import { ContentCard } from "@/components/public/ui";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
import { RegisterForm } from "@/components/auth/register-form";
|
||||
import { captchaConfig } from "@/lib/services/captcha";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -14,51 +12,32 @@ export default async function RegisterPage({
|
||||
}) {
|
||||
const t = await getTranslations("pages.register");
|
||||
const { error } = await searchParams;
|
||||
const captcha = await captchaConfig();
|
||||
const showCaptcha = captcha.provider !== "none" && !!captcha.siteKey;
|
||||
|
||||
const [hotelName, imager, captcha, femaleFigures, maleFigures] = await Promise.all([
|
||||
siteSettings.get("hotel_name", "Atom"),
|
||||
siteSettings.get("habbo_imaging_url", "https://www.habbo.com/habbo-imaging/avatarimage"),
|
||||
captchaConfig(),
|
||||
siteSettings.get("register_female_figures", "hr-100-45.hd-180-1.ch-215-62.lg-270-62.sh-290-62,hr-130-45.hd-180-2.ch-220-62.lg-280-62.sh-305-62,hr-140-45.hd-180-3.ch-225-62.lg-270-62.sh-310-62,hr-165-45.hd-180-1.ch-210-62.lg-270-62.sh-290-62,hr-190-45.hd-180-2.ch-215-62.lg-270-62.sh-305-62"),
|
||||
siteSettings.get("register_male_figures", "hr-100-61.hd-180-1.ch-210-66.lg-270-110.sh-305-62,hr-105-61.hd-190-2.ch-215-66.lg-280-110.sh-310-62,hr-110-61.hd-200-3.ch-220-66.lg-290-110.sh-320-62,hr-115-61.hd-185-1.ch-210-66.lg-275-110.sh-315-62,hr-120-61.hd-180-2.ch-205-66.lg-285-110.sh-305-62"),
|
||||
]);
|
||||
|
||||
const allFigures = [
|
||||
...(femaleFigures?.split(",").filter(Boolean) || []),
|
||||
...(maleFigures?.split(",").filter(Boolean) || []),
|
||||
];
|
||||
|
||||
return (
|
||||
<main style={{ maxWidth: 420, margin: "2rem auto" }}>
|
||||
<ContentCard
|
||||
icon="🎉"
|
||||
title={t("title")}
|
||||
subtitle={t("subtitle")}
|
||||
>
|
||||
<form action={register} style={{ display: "grid", gap: "0.7rem" }}>
|
||||
<input name="username" placeholder={t("usernamePlaceholder")} autoComplete="username" required />
|
||||
<input name="mail" type="email" placeholder={t("emailPlaceholder")} autoComplete="email" required />
|
||||
<input
|
||||
name="password"
|
||||
type="password"
|
||||
placeholder={t("passwordPlaceholder")}
|
||||
autoComplete="new-password"
|
||||
required
|
||||
/>
|
||||
{showCaptcha && captcha.provider === "turnstile" ? (
|
||||
<div className="cf-turnstile" data-sitekey={captcha.siteKey} />
|
||||
) : null}
|
||||
{showCaptcha && captcha.provider === "recaptcha" ? (
|
||||
<div className="g-recaptcha" data-sitekey={captcha.siteKey} />
|
||||
) : null}
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("register")}
|
||||
</button>
|
||||
</form>
|
||||
{showCaptcha && captcha.provider === "turnstile" ? (
|
||||
<Script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer />
|
||||
) : null}
|
||||
{showCaptcha && captcha.provider === "recaptcha" ? (
|
||||
<Script src="https://www.google.com/recaptcha/api.js" async defer />
|
||||
) : null}
|
||||
{error ? (
|
||||
<p style={{ color: "var(--color-danger)", textAlign: "center", marginBottom: 0 }}>
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
<p className="muted" style={{ textAlign: "center", marginBottom: 0, marginTop: "1rem" }}>
|
||||
{t("alreadyHaveAccount")} <Link href="/login">{t("signIn")}</Link>
|
||||
</p>
|
||||
</ContentCard>
|
||||
<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
|
||||
initialFigures={allFigures}
|
||||
imager={imager ?? ""}
|
||||
hotelName={hotelName ?? "Atom"}
|
||||
captcha={captcha}
|
||||
error={error}
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user