import { InformationCircleIcon } from '@heroicons/react/24/outline'; import { passwordStrength } from 'check-password-strength'; import clsx from 'clsx'; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { HoverCard, HoverCardContent, HoverCardTrigger, // eslint-disable-next-line import/extensions } from '@/components/ui/hover-card'; type PasswordStrengthCardProps = { password: string; }; export const PasswordStrengthCard: React.FC = ({ password, }) => { const { t } = useTranslation(); const [strength, setStrength] = useState(passwordStrength(password)); useEffect(() => { setStrength(passwordStrength(password)); }, [password]); let cardText = { title: t('noPasswordTitle'), text: t('noPasswordText'), }; if (password !== '') { switch (strength.value) { case 'Strong': cardText = { title: t('strongPasswordTitle'), text: t('strongPasswordText'), }; break; case 'Medium': cardText = { title: t('mediumPasswordTitle'), text: t('mediumPasswordText'), }; break; case 'Weak': cardText = { title: t('weakPasswordTitle'), text: t('weakPasswordText'), }; break; case 'Too weak': cardText = { title: t('tooWeakPasswordTitle'), text: t('tooWeakPasswordText'), }; break; default: cardText = { title: t('noPasswordTitle'), text: t('noPasswordText'), }; break; } } return (

{cardText.title}

{cardText.text}

{t('passwordStrengthInfo')}

{t('passwordStrengthInfo')}

); };