import { Box, FieldHint, FieldLabel, FieldRow, RadioButton } from '@rocket.chat/fuselage'; import DOMPurify from 'dompurify'; import { useId } from 'react'; import type { Control, UseFormSetValue } from 'react-hook-form'; import { Controller } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import type { UserFormProps } from './AdminUserForm'; type AdminUserSetRandomPasswordProps = { isNewUserPage: boolean | undefined; control: Control; isSmtpEnabled: boolean | undefined; setRandomPasswordId: string; setValue: UseFormSetValue; }; const AdminUserSetRandomPasswordRadios = ({ isNewUserPage, control, isSmtpEnabled, setRandomPasswordId, setValue, }: AdminUserSetRandomPasswordProps) => { const { t } = useTranslation(); const setPasswordManuallyId = useId(); const handleSetRandomPasswordChange = (onChange: (...event: any[]) => void, value: boolean) => { setValue('requirePasswordChange', value); onChange(value); }; return ( <> ( handleSetRandomPasswordChange(onChange, true)} disabled={!isSmtpEnabled} /> )} /> {t('Set_randomly_and_send_by_email')} {!isSmtpEnabled && ( )} ( handleSetRandomPasswordChange(onChange, false)} /> )} /> {t('Set_manually')} ); }; export default AdminUserSetRandomPasswordRadios;