'use client'; import { useState } from 'react'; import { LogIn } from 'lucide-react'; import { useAtprotoSession } from '@/components/AtprotoSessionProvider'; import ScopeSelector from '@/components/oauth/ScopeSelector'; /** * Compact sign-in form used inside the record view's action row. Accepts a * handle / DID; redirects out to the user's OAuth provider via a two-step * flow that lets the user pick which permissions to grant. */ export default function SignInPanel({ defaultInput }: { defaultInput?: string }) { const { signIn } = useAtprotoSession(); const [value, setValue] = useState(defaultInput || ''); const [step, setStep] = useState<'handle' | 'scopes'>('handle'); const [pendingAccount, setPendingAccount] = useState(''); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); if (step === 'scopes') { return (
{ setStep('handle'); setError(null); }} onContinue={async (scopeString) => { setBusy(true); setError(null); try { await signIn(pendingAccount, scopeString); } catch (err) { setBusy(false); setError(err instanceof Error ? err.message : String(err)); } }} />
); } return (
{ e.preventDefault(); const v = value.trim(); if (!v) return; setError(null); setPendingAccount(v); setStep('scopes'); }} style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'stretch', gap: '0.5rem', }} > setValue(e.target.value)} style={{ flex: '1 1 220px', minWidth: 0, padding: '0.55rem 0.75rem', background: 'var(--bg-tertiary)', border: '1px solid var(--border-medium)', color: 'var(--text-primary)', fontFamily: 'var(--font-mono)', fontSize: '0.85rem', outline: 'none', }} /> {error && (

{error}

)}
); }