diff --git a/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/finish/password-reset-finish.tsx.ejs b/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/finish/password-reset-finish.tsx.ejs index 0ca7d11638ba..64d0d582f8a7 100644 --- a/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/finish/password-reset-finish.tsx.ejs +++ b/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/finish/password-reset-finish.tsx.ejs @@ -70,7 +70,7 @@ export const PasswordResetFinishPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="newPassword" + nameIdCy="newPassword" validate={{ required: translate('global.messages.validate.newpassword.required') , minLength: { value: 4, message: translate('global.messages.validate.newpassword.minlength') }, @@ -87,7 +87,7 @@ export const PasswordResetFinishPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="confirmPassword" + nameIdCy="confirmPassword" validate={{ required: translate('global.messages.validate.confirmpassword.required'), minLength: { value: 4, message: translate('global.messages.validate.confirmpassword.minlength') }, diff --git a/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/init/password-reset-init.tsx.ejs b/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/init/password-reset-init.tsx.ejs index aa15c272647b..6c2dc63d23ad 100644 --- a/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/init/password-reset-init.tsx.ejs +++ b/generators/client/templates/react/src/main/webapp/app/modules/account/password-reset/init/password-reset-init.tsx.ejs @@ -71,7 +71,7 @@ export const PasswordResetInit = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="email" + nameIdCy="email" validate={ { required: translate('global.messages.validate.email.required'), minLength: { value: 5, message: translate('global.messages.validate.email.minlength') }, diff --git a/generators/client/templates/react/src/main/webapp/app/modules/account/password/password.tsx.ejs b/generators/client/templates/react/src/main/webapp/app/modules/account/password/password.tsx.ejs index 97775537fd44..812b8ab5eae3 100644 --- a/generators/client/templates/react/src/main/webapp/app/modules/account/password/password.tsx.ejs +++ b/generators/client/templates/react/src/main/webapp/app/modules/account/password/password.tsx.ejs @@ -80,7 +80,7 @@ export const PasswordPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="currentPassword" + nameIdCy="currentPassword" validate={{ required: translate('global.messages.validate.newpassword.required') }} labelPlaceholderKey="global.form.currentpassword.label" inputPlaceholderKey="global.form.currentpassword.placeholder" @@ -91,7 +91,7 @@ export const PasswordPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="newPassword" + nameIdCy="newPassword" validate={{ required: translate('global.messages.validate.newpassword.required'), minLength: { value: 4, message: translate('global.messages.validate.newpassword.minlength') }, @@ -108,7 +108,7 @@ export const PasswordPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="confirmPassword" + nameIdCy="confirmPassword" validate={{ required: translate('global.messages.validate.confirmpassword.required'), minLength: { value: 4, message: translate('global.messages.validate.confirmpassword.minlength') }, diff --git a/generators/client/templates/react/src/main/webapp/app/modules/account/register/register.tsx.ejs b/generators/client/templates/react/src/main/webapp/app/modules/account/register/register.tsx.ejs index 52c6281ef3c8..ef59b1c32e66 100644 --- a/generators/client/templates/react/src/main/webapp/app/modules/account/register/register.tsx.ejs +++ b/generators/client/templates/react/src/main/webapp/app/modules/account/register/register.tsx.ejs @@ -82,7 +82,7 @@ export const RegisterPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="username" + nameIdCy="username" validate={{ required: translate('register.messages.validate.login.required'), pattern: { @@ -100,7 +100,7 @@ export const RegisterPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="email" + nameIdCy="email" type="email" validate={{ required: translate('global.messages.validate.email.required'), @@ -116,7 +116,7 @@ export const RegisterPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="firstPassword" + nameIdCy="firstPassword" type="password" validate={{ required: translate('global.messages.validate.newpassword.required'), @@ -133,7 +133,7 @@ export const RegisterPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="secondPassword" + nameIdCy="secondPassword" type="password" validate={{ required: translate('global.messages.validate.confirmpassword.required'), diff --git a/generators/client/templates/react/src/main/webapp/app/modules/account/settings/settings.tsx.ejs b/generators/client/templates/react/src/main/webapp/app/modules/account/settings/settings.tsx.ejs index 25663caad599..ce9cf6d4f233 100644 --- a/generators/client/templates/react/src/main/webapp/app/modules/account/settings/settings.tsx.ejs +++ b/generators/client/templates/react/src/main/webapp/app/modules/account/settings/settings.tsx.ejs @@ -27,7 +27,7 @@ import { locales, languages } from 'app/config/translation'; import { useAppDispatch, useAppSelector } from 'app/config/store'; import { getSession } from 'app/shared/reducers/authentication'; import { saveAccountSettings, reset } from './settings.reducer'; -import { useForm } from 'react-hook-form'; +import { DefaultValues, FieldValues, useForm } from 'react-hook-form'; export const SettingsPage = () => { const dispatch = useAppDispatch(); @@ -38,7 +38,16 @@ export const SettingsPage = () => { handleSubmit, setValue, formState: { errors, touchedFields }, - } = useForm(); + } = useForm({ + defaultValues: { + firstName: account?.firstName, + lastName: account?.lastName, + email: account?.email, +<%_ if (enableTranslation) { _%> + langKey: account?.langKey, +<%_ } _%> + } as DefaultValues + }); useEffect(() => { dispatch(getSession()); @@ -76,13 +85,13 @@ export const SettingsPage = () => { {/* eslint-disable-next-line @typescript-eslint/no-misused-promises */} -
+ { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="lastName" + nameIdCy="lastName" validate={{ required: translate('settings.messages.validate.lastname.required'), minLength: { value: 1, message: translate('settings.messages.validate.lastname.minlength') }, @@ -110,7 +119,7 @@ export const SettingsPage = () => { touchedFields={ touchedFields } errors={ errors } setValue={ setValue } - name="email" + nameIdCy="email" type="email" validate={{ required: translate('global.messages.validate.email.required'), diff --git a/generators/client/templates/react/src/main/webapp/app/modules/administration/user-management/user-management-update.tsx.ejs b/generators/client/templates/react/src/main/webapp/app/modules/administration/user-management/user-management-update.tsx.ejs index b5566c07171b..760caba1ba17 100644 --- a/generators/client/templates/react/src/main/webapp/app/modules/administration/user-management/user-management-update.tsx.ejs +++ b/generators/client/templates/react/src/main/webapp/app/modules/administration/user-management/user-management-update.tsx.ejs @@ -16,11 +16,12 @@ See the License for the specific language governing permissions and limitations under the License. -%> -import React, { useState, useEffect } from 'react'; +import React, { useEffect } from 'react'; import { Link, useNavigate, useParams } from 'react-router-dom'; -import { Button, Row, Col, FormText } from 'reactstrap'; -import { Translate, translate, ValidatedField, ValidatedForm, isEmail } from 'react-jhipster'; +import { Button, Row, Col, Form, Input } from 'reactstrap'; +import { Translate, translate, ValidatedTextInput, isEmail } from 'react-jhipster'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { useForm } from 'react-hook-form'; <%_ if (enableTranslation) { _%> import { locales, languages } from 'app/config/translation'; @@ -66,6 +67,23 @@ export const UserManagementUpdate = () => { const loading = useAppSelector(state => state.userManagement.loading); const updating = useAppSelector(state => state.userManagement.updating); const authorities = useAppSelector(state => state.userManagement.authorities); + const { + register, + handleSubmit, + setValue, + formState: { errors, touchedFields }, + } = useForm({ + defaultValues: { + id: user?.id, + login: user?.login, + firstName: user?.firstName, + lastName: user?.lastName, + email: user?.email, + activated: user?.activated, + langKey: user?.langKey, + authorities: user?.authorities, + } as DefaultValues + }); return (
@@ -79,108 +97,119 @@ export const UserManagementUpdate = () => { { loading ?

Loading...

- : + /* eslint-disable-next-line @typescript-eslint/no-misused-promises */ + : {user.id ? ( - + ) : null} + /, + message: translate('register.messages.validate.login.pattern'), + }, + minLength: { + value: 1, + message: translate('register.messages.validate.login.minlength'), + }, + maxLength: { + value: 50, + message: translate('register.messages.validate.login.maxlength'), + }, + }} + labelPlaceholderKey="userManagement.login" + /> + + + isEmail(v) || translate('global.messages.validate.email.invalid'), + }} + labelPlaceholderKey="global.form.email.label" + inputPlaceholderKey="global.form.email.placeholder" + /> + - ) : null} - /, - message: translate('register.messages.validate.login.pattern'), - }, - minLength: { - value: 1, - message: translate('register.messages.validate.login.minlength'), - }, - maxLength: { - value: 50, - message: translate('register.messages.validate.login.maxlength'), - }, - }} - /> - - - This field cannot be longer than 50 characters. - isEmail(v) || translate('global.messages.validate.email.invalid'), - }} - /> - <%_ if (enableTranslation) { _%> - + {locales.map(locale => ( ))} - + <%_ } _%> - + {authorities.map(role => ( ))} - + - + }