Template
PostHog loads after the page is idle through a same-origin /ingest proxy and follows the signed-in Convex user. Plausible uses the per-site script through a /pa proxy, clear of Payload's /api routes. Sentry keeps errors and traces only. Pages load only the @gib/ui modules they import, and client code reads public env from publicEnv.ts so zod stays out of the browser.
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
import { resetAnalyticsIdentity } from '@/lib/analytics';
|
|
import { useAuthActions } from '@convex-dev/auth/react';
|
|
import { LogOut } from 'lucide-react';
|
|
|
|
import {
|
|
Button,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from '@gib/ui';
|
|
|
|
export const SignOutForm = () => {
|
|
const { signOut } = useAuthActions();
|
|
const router = useRouter();
|
|
const [isSigningOut, setIsSigningOut] = useState(false);
|
|
|
|
const handleSignOut = async () => {
|
|
setIsSigningOut(true);
|
|
try {
|
|
await signOut();
|
|
resetAnalyticsIdentity();
|
|
router.push('/');
|
|
} catch (error) {
|
|
console.error('Sign out error:', error);
|
|
setIsSigningOut(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<CardHeader>
|
|
<CardTitle>Sign Out</CardTitle>
|
|
<CardDescription>
|
|
End your current session and return to the home page
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Button
|
|
variant='destructive'
|
|
className='w-full'
|
|
onClick={handleSignOut}
|
|
disabled={isSigningOut}
|
|
>
|
|
<LogOut className='mr-2 h-4 w-4' />
|
|
{isSigningOut ? 'Signing Out...' : 'Sign Out'}
|
|
</Button>
|
|
</CardContent>
|
|
</>
|
|
);
|
|
};
|