import Link from 'next/link';
import { Video, UserPlus, LogIn, MailWarning } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import type { InvitationPreview } from '@/lib/invitations';
interface InvitationLandingProps {
token: string;
preview: InvitationPreview | null;
}
function Shell({ children }: { children: React.ReactNode }) {
return (
);
}
function UnusableInvitation({ title, message }: { title: string; message: string }) {
return (
{title}
{message}
Sign in
Ask whoever invited you to send a new invitation link.
);
}
/** Too many unauthenticated invitation lookups from this client — nothing was queried. */
export function InvitationRateLimited() {
return (
);
}
/** Signed in, but with an account whose address the invitation was not issued to. */
export function InvitationAccountMismatch({
invitedEmail,
signedInEmail,
}: {
invitedEmail: string;
signedInEmail: string;
}) {
return (
Wrong account
This invitation was sent to {invitedEmail} , but you are signed in as{' '}
{signedInEmail} .
Sign out and switch account
Back to dashboard
After signing out, open the invitation link from your email again.
);
}
export function InvitationLanding({ token, preview }: InvitationLandingProps) {
const acceptPath = `/invitations/accept?token=${encodeURIComponent(token)}`;
const loginHref = `/login?callbackUrl=${encodeURIComponent(acceptPath)}`;
if (!preview) {
return (
);
}
if (preview.status === 'CANCELED') {
return (
);
}
if (preview.status === 'EXPIRED' || preview.isExpired) {
return (
);
}
const registerHref =
`/register?invitationToken=${encodeURIComponent(token)}` +
`&email=${encodeURIComponent(preview.email)}` +
`&callbackUrl=${encodeURIComponent(acceptPath)}`;
const alreadyAccepted = preview.status === 'ACCEPTED';
const targetLabel = preview.targetName
? `${preview.targetName} (${preview.scopeLabel})`
: `a ${preview.scopeLabel}`;
return (
You've been invited
{preview.inviterName} invited you to join {targetLabel} on OpenFrame as{' '}
{preview.roleLabel}.
This invitation was sent to{' '}
{preview.email} .{' '}
{preview.hasAccount || alreadyAccepted ? 'Sign in with' : 'Use'} that address to
accept it.
{preview.hasAccount || alreadyAccepted ? (
<>
Sign in to accept
{!alreadyAccepted && (
Wrong address?{' '}
Create an account instead
)}
>
) : (
<>
You don't have an OpenFrame account yet. Create one to open this{' '}
{preview.scopeLabel} — we'll bring you right back here once you're signed
in.
Create your account
Already have an account?{' '}
Sign in
>
)}
);
}