import { useMemo } from 'react' import { Loader2, Send, Shield, UserRound, type LucideIcon } from 'lucide-react' import { useTranslation } from 'react-i18next' import { SiGithub, SiLinux, SiWechat } from 'react-icons/si' import { AuthLayout } from '../auth-layout' type OAuthCallbackScreenProps = { provider: string mode: 'login' | 'bind' } type ProviderMeta = { label: string Icon: LucideIcon | ((props: { className?: string }) => React.JSX.Element) } const providerDictionary: Record = { github: { label: 'GitHub', Icon: (props: { className?: string }) => ( ), }, oidc: { label: 'OIDC', Icon: Shield }, linuxdo: { label: 'LinuxDO', Icon: (props: { className?: string }) => ( ), }, telegram: { label: 'Telegram', Icon: Send }, wechat: { label: 'WeChat', Icon: (props: { className?: string }) => ( ), }, } export function OAuthCallbackScreen({ provider, mode, }: OAuthCallbackScreenProps) { const { t } = useTranslation() const { label, Icon } = useMemo(() => { const normalized = provider?.toLowerCase() ?? '' return ( providerDictionary[normalized] || { label: 'account', Icon: UserRound, } ) }, [provider]) const providerLabel = t(label) const isBindMode = mode === 'bind' const headline = isBindMode ? t('Binding your {{provider}} account', { provider: providerLabel }) : t('Signing you in with {{provider}}', { provider: providerLabel }) const description = isBindMode ? t('Hang tight while we securely link this account to your profile.') : t('Hang tight while we finish connecting your account.') const secondaryNote = isBindMode ? t( 'You can close this tab once the binding completes or a success message appears in the original window.' ) : t( "You'll be redirected automatically. You can return to the previous page if nothing happens after a few seconds." ) return (

{headline}

{description}

{t('Processing OAuth response...')}

{secondaryNote}

{t( 'This may take a few moments while we validate the request and update your session.' )}

) }