Initial PHP rebuild of the app
This commit is contained in:
690 files changed
+33944
-12046
No files matched your search
@@ -1,51 +0,0 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { prisma } from "@/lib/db/prisma";
|
||||
import { validateInvitationToken } from "@/services/staff/staff-invitation.service";
|
||||
import { AcceptInvitationForm } from "@/features/auth/components/accept-invitation-form";
|
||||
|
||||
export const metadata: Metadata = { title: "Accept Invitation" };
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function AcceptInvitationPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ token?: string }>;
|
||||
}) {
|
||||
const { token } = await searchParams;
|
||||
|
||||
if (!token) {
|
||||
return <InvalidInvitation message="This invitation link is missing its token." />;
|
||||
}
|
||||
|
||||
const check = await validateInvitationToken(prisma, token);
|
||||
if (!check.valid) {
|
||||
const message =
|
||||
check.reason === "EXPIRED"
|
||||
? "This invitation link has expired. Ask the business owner to send you a new one."
|
||||
: check.reason === "ALREADY_ACCEPTED"
|
||||
? "This invitation has already been used."
|
||||
: "This invitation link isn't valid.";
|
||||
return <InvalidInvitation message={message} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="mb-2 text-3xl font-bold tracking-tight">Welcome, {check.invitation.staff.user.name}</h1>
|
||||
<p className="text-muted mb-10">Finish setting up your staff account.</p>
|
||||
<AcceptInvitationForm token={token} businessName={check.invitation.staff.business.name} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function InvalidInvitation({ message }: { message: string }) {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="mb-2 text-3xl font-bold tracking-tight">Invitation Not Available</h1>
|
||||
<p className="text-muted mb-10">{message}</p>
|
||||
<Link href="/sign-in" className="border-ink text-ink border-b font-bold text-sm">
|
||||
Go to Sign In
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user