In theory all done expect En|es and light/dark

This commit is contained in:
mdares
2026-01-04 00:53:00 +00:00
parent b6eed8b6db
commit 538b06bd4b
2 changed files with 67 additions and 9 deletions

View File

@@ -1,12 +1,52 @@
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { prisma } from "@/lib/prisma";
import InviteAcceptForm from "./InviteAcceptForm";
export default async function InvitePage({ params }: { params: { token: string } }) {
export default async function InvitePage({ params }: { params: { token: string } | Promise<{ token: string }> }) {
const session = (await cookies()).get("mis_session")?.value;
if (session) {
redirect("/machines");
}
return <InviteAcceptForm token={params.token} />;
const resolvedParams = await Promise.resolve(params);
const token = String(resolvedParams?.token || "").trim().toLowerCase();
let invite = null;
let error: string | null = null;
if (!token) {
error = "Invite not found";
} else {
invite = await prisma.orgInvite.findFirst({
where: {
token,
revokedAt: null,
acceptedAt: null,
expiresAt: { gt: new Date() },
},
include: {
org: { select: { id: true, name: true, slug: true } },
},
});
if (!invite) {
error = "Invite not found";
}
}
return (
<InviteAcceptForm
token={token}
initialInvite={
invite
? {
email: invite.email,
role: invite.role,
org: invite.org,
expiresAt: invite.expiresAt.toISOString(),
}
: null
}
initialError={error}
/>
);
}