import * as AlertDialog from '@radix-ui/react-alert-dialog'; import { useQueryClient } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; import { toast } from 'sonner'; import { useNDK } from '@libs/ndk/provider'; import { useStorage } from '@libs/storage/provider'; export function Logout() { const { db } = useStorage(); const { ndk } = useNDK(); const navigate = useNavigate(); const queryClient = useQueryClient(); const logout = async () => { try { ndk.signer = null; // remove private key await db.secureRemove(db.account.pubkey); await db.secureRemove(`${db.account.pubkey}-nsecbunker`); // logout await db.accountLogout(); // clear cache queryClient.clear(); // redirect to welcome screen navigate('/auth/welcome'); } catch (e) { toast.error(e); } }; return (
Are you sure! You can always log back in at any time. If you just want to switch accounts, you can do that by adding an existing account.
); }