import React, { useState } from 'react'; import { FormGroup, FormHelperText, HelperText, HelperTextItem, InputGroup, InputGroupItem, TextInput, Button, TextInputProps, } from '@patternfly/react-core'; import { EyeIcon, EyeSlashIcon } from '@patternfly/react-icons'; import { checkPasswordValidity } from './useValidation'; import { useAppSelector } from '../../../store/hooks'; import { selectImageTypes } from '../../../store/wizardSlice'; type ValidatedPasswordInput = TextInputProps & { value: string; placeholder: string; ariaLabel: string; onChange: (event: React.FormEvent, value: string) => void; hasPassword: boolean; }; export const PasswordValidatedInput = ({ value, placeholder, ariaLabel, onChange, hasPassword, }: ValidatedPasswordInput) => { const environments = useAppSelector(selectImageTypes); const [isPasswordVisible, setIsPasswordVisible] = useState(false); const { validationState } = checkPasswordValidity( value, environments.includes('azure') ); const { ruleLength, ruleCharacters } = validationState; const togglePasswordVisibility = () => { setIsPasswordVisible(!isPasswordVisible); }; return ( <> Password must be at least 6 characters long {environments.includes('azure') && ( Must include at least 3 of the following: lowercase letters, uppercase letters, numbers, symbols )} ); };