'use client'; import { useState } from 'react'; import { DateTime } from 'luxon'; import { signOut } from 'next-auth/react'; import { trpc } from '@documenso/trpc/react'; import { Button } from '@documenso/ui/primitives/button'; import { useToast } from '@documenso/ui/primitives/use-toast'; export type SigningAuthPageViewProps = { email: string; }; export const SigningAuthPageView = ({ email }: SigningAuthPageViewProps) => { const { toast } = useToast(); const [isSigningOut, setIsSigningOut] = useState(false); const { mutateAsync: encryptSecondaryData } = trpc.crypto.encryptSecondaryData.useMutation(); const handleChangeAccount = async (email: string) => { try { setIsSigningOut(true); const encryptedEmail = await encryptSecondaryData({ data: email, expiresAt: DateTime.now().plus({ days: 1 }).toMillis(), }); await signOut({ callbackUrl: `/signin?email=${encodeURIComponent(encryptedEmail)}`, }); } catch { toast({ title: 'Something went wrong', description: 'We were unable to log you out at this time.', duration: 10000, variant: 'destructive', }); } setIsSigningOut(false); }; return (
You need to be logged in as {email} to view this page.