In theory all done expect En|es and light/dark
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user