lomavuokraus/app/verify/page.tsx
Tero Halla-aho 0bb709d9c5
Some checks failed
CI / checks (push) Has been cancelled
chore: fix audit alerts and formatting
2026-02-04 12:43:03 +02:00

43 lines
1.2 KiB
TypeScript

import { notFound } from "next/navigation";
import { cookies, headers } from "next/headers";
import { resolveLocale, t } from "../../lib/i18n";
type Props = {
searchParams: { token?: string };
};
export default async function VerifyPage({ searchParams }: Props) {
const token = searchParams.token;
if (!token) {
notFound();
}
const cookieStore = await cookies();
const headerList = await headers();
const locale = resolveLocale({
cookieLocale: cookieStore.get("locale")?.value,
acceptLanguage: headerList.get("accept-language"),
});
const translate = (key: any) => t(locale, key as any);
const res = await fetch(
`${process.env.APP_URL ?? "http://localhost:3000"}/api/auth/verify`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token }),
cache: "no-store",
},
);
const ok = res.ok;
return (
<main className="panel" style={{ maxWidth: 520, margin: "40px auto" }}>
<h1>{translate("verifyTitle")}</h1>
{ok ? (
<p>{translate("verifyOk")}</p>
) : (
<p style={{ color: "red" }}>{translate("verifyFail")}</p>
)}
</main>
);
}