'use client'; import { useMemo } from 'react'; import dynamic from 'next/dynamic'; import { Lightbulb } from 'lucide-react'; import { If } from '@kit/ui/if'; import { Trans } from '@kit/ui/trans'; import { useLastAuthMethod } from '../hooks/use-last-auth-method'; interface LastAuthMethodHintProps { className?: string; } // we force dynamic import to avoid hydration errors export const LastAuthMethodHint = dynamic( async () => ({ default: LastAuthMethodHintImpl }), { ssr: false, }, ); function LastAuthMethodHintImpl({ className }: LastAuthMethodHintProps) { const { hasLastMethod, methodType, providerName, isOAuth } = useLastAuthMethod(); // Get the appropriate translation key based on the method - memoized // This must be called before any conditional returns to follow Rules of Hooks const methodKey = useMemo(() => { switch (methodType) { case 'password': return 'auth:methodPassword'; case 'otp': return 'auth:methodOtp'; case 'magic_link': return 'auth:methodMagicLink'; case 'oauth': return 'auth:methodOauth'; default: return null; } }, [methodType]); // Don't show anything until loaded or if no last method if (!hasLastMethod) { return null; } if (!methodKey) { return null; // If method is not recognized, don't render anything } return (