import { useState } from "react"; import { Link } from "react-router"; import { Badge } from "~/components/ui/badge"; import { Button } from "~/components/ui/button"; import { authClient } from "~/lib/auth-client"; type LinkedAccount = { id: string; providerId: string; }; type Props = { email: string; linkedAccounts: LinkedAccount[]; }; const PROVIDER_LABELS: Record = { credential: "Email & Password", google: "Google", discord: "Discord", }; export function AccountSection({ email, linkedAccounts }: Props) { const [linkingDiscord, setLinkingDiscord] = useState(false); const [linkError, setLinkError] = useState(null); const hasPassword = linkedAccounts.some((a) => a.providerId === "credential"); const oauthAccounts = linkedAccounts.filter((a) => a.providerId !== "credential"); const hasDiscord = linkedAccounts.some((a) => a.providerId === "discord"); async function handleConnectDiscord() { setLinkingDiscord(true); setLinkError(null); try { await authClient.linkSocial({ provider: "discord", callbackURL: "/settings/account" }); } catch { setLinkError("Failed to connect Discord. Please try again."); setLinkingDiscord(false); } } return (

Account

Your login email and connected providers.

Email Address

{email}

Sign-in Methods

{hasPassword && (
Email & Password Active
)} {oauthAccounts.map((account) => (
{PROVIDER_LABELS[account.providerId] ?? account.providerId} Connected
))} {linkedAccounts.length === 0 && (

No sign-in methods found.

)}
{!hasDiscord && (
{linkError && (

{linkError}

)}
)}
{hasPassword && (

Password

To change your password, use the forgot password flow.

Reset password
)}
); }