import React, { useId, useState } from 'react'; import { cn } from '@/lib/utils'; import { Eye, EyeOff } from 'lucide-react'; interface AuthInputProps extends React.InputHTMLAttributes { error?: string; label?: string; showPasswordToggle?: boolean; } export function AuthInput({ error, label, className, id, showPasswordToggle, type, ...props }: AuthInputProps) { // CRITIQUE FIX #5: Utiliser useId() de React pour générer un ID stable // qui ne change pas entre les renders, contrairement à Math.random() const generatedId = useId(); const inputId = id || generatedId; const [showPassword, setShowPassword] = useState(false); const inputType = type === 'password' && showPassword ? 'text' : type; const hasToggle = type === 'password' && showPasswordToggle; return (
{label && ( )}
{/* Password visibility toggle */} {hasToggle && ( )}
{error && ( )}
); }