import type { MinecraftCredentials } from '@/bindings.gen'; import { AccountAvatar, isMinecraftAuthError, MinecraftAuthErrorModal, Overlay } from '@/components'; import { bindings } from '@/main'; import { useCommandMut } from '@onelauncher/common'; import { useQueryClient } from '@tanstack/react-query'; import { useState } from 'react'; export function AddAccountModal() { return ( Add Account

Add a new account to OneClient

); } export function AddAccountModalButton() { const queryClient = useQueryClient(); const [authError, setAuthError] = useState(null); const { data: profile, isPending, mutate: login } = useCommandMut(bindings.core.openMsaLogin, { onSuccess(data) { setAuthError(null); queryClient.invalidateQueries({ queryKey: ['getUsers'], }); queryClient.invalidateQueries({ queryKey: ['getDefaultUser'], }); }, onError(error) { console.error('[auth] AddAccountModal: openMsaLogin failed', error); if (isMinecraftAuthError(error)) setAuthError(error); }, }); const onClick = () => { setAuthError(null); login(); }; if (authError) return ; return ( profile ? ( <> ) : ); } function AccountRow({ profile }: { profile: MinecraftCredentials }) { return (

{profile.username}

{profile.id}

); }