Polish invitation resend and upload recovery

This commit is contained in:
2026-09-10 11:53:59 -04:00
parent 361e14ec1d
commit d44ef7348c
15 changed files with 208 additions and 23 deletions
@@ -54,7 +54,7 @@ export default async function InvitationPage({
</CardHeader>
<CardContent className="flex flex-col gap-3">
<p className="text-sm text-muted-foreground">This invitation grants team access, not a guest RSVP. Your assigned role controls what you can view and manage.</p>
{session ? <RedeemInviteButton token={token} /> : <>
{session ? <RedeemInviteButton token={token} unverifiedEmail={!session.user.emailVerified ? session.user.email : undefined} /> : <>
<Button asChild><Link href={`/sign-up?invite=${encodeURIComponent(token)}&callbackURL=${encodeURIComponent(callback)}`}>Create account to accept</Link></Button>
<Button asChild variant="outline"><Link href={`/sign-in?callbackURL=${encodeURIComponent(callback)}`}>Already have an account? Sign in</Link></Button>
</>}
@@ -5,8 +5,11 @@ import { toast } from "sonner";
import { api } from "@/trpc/react";
import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
import { useState } from "react";
import { authClient } from "@/lib/auth-client";
export function RedeemInviteButton({ token }: { token: string }) {
export function RedeemInviteButton({ token, unverifiedEmail }: { token: string; unverifiedEmail?: string }) {
const [sending, setSending] = useState(false);
const router = useRouter();
const redeem = api.invites.redeem.useMutation({
onSuccess: (result) => {
@@ -21,6 +24,12 @@ export function RedeemInviteButton({ token }: { token: string }) {
onError: (error) => toast.error(error.message),
});
if (unverifiedEmail) return <div className="flex flex-col gap-3"><p>Verify your email before accepting. Open the verification link in your inbox, then return here.</p><Button disabled={sending} onClick={async () => {
setSending(true);
try { const result = await authClient.sendVerificationEmail({ email: unverifiedEmail, callbackURL: `/invitations/${encodeURIComponent(token)}` }); if (result.error) throw new Error(result.error.message); toast.success("Verification email sent"); }
catch { toast.error("Could not send verification email. Try again shortly."); }
finally { setSending(false); }
}}>{sending ? "Sending…" : "Resend verification email"}</Button></div>;
return (
<Button
onClick={() => redeem.mutate({ token })}