Skip to content

Commit

Permalink
input id changed, novalidate form removed, btn disabled added
Browse files Browse the repository at this point in the history
  • Loading branch information
Lvyshnevska committed Oct 10, 2024
1 parent 5442ee6 commit ca33389
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion FrontEnd/src/components/MiniComponents/AdminSubmitButton.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import classes from './AdminSubmitButton.module.css';

const AdminSubmitButton = () => {
const AdminSubmitButton = ({ disabled }) => {
return (
<div className={classes['admin-submit__container']}>
<button
className={classes['admin-submit__button']}
type="submit"
disabled={disabled}
>
Зберегти зміни
</button>
Expand Down
4 changes: 2 additions & 2 deletions FrontEnd/src/pages/AdminPage/AdminProfile/AdminInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const AdminInfo = ({ user, mutate }) => {
handleSubmit,
setValue,
getValues,
formState: { errors },
formState: { errors, isDirty },
} = useForm({
defaultValues: {
'name': user.name,
Expand Down Expand Up @@ -129,7 +129,7 @@ const AdminInfo = ({ user, mutate }) => {
{errors.surname && errors.surname.message}
</div>
</div>
<AdminSubmitButton />
<AdminSubmitButton disabled={!isDirty}/>
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function ChangeAdminPassword(props) {
getValues,
watch,
reset,
formState: { errors },
formState: { errors, isDirty },
} = useForm({
mode: 'all',
defaultValues: {
Expand Down Expand Up @@ -55,14 +55,13 @@ export default function ChangeAdminPassword(props) {
return (
<div className={classes['form__container']}>
{props.user ? (
<form id="ChangePassword" onSubmit={handleSubmit(handleFormSubmit)} noValidate >
<form id="ChangeAdminPassword" onSubmit={handleSubmit(handleFormSubmit)} >
<PasswordField
inputId="currentPassword"
inputId="currentAdminPassword"
name="currentPassword"
label="Поточний пароль"
register={register}
error={errors}
showError={false}
watch={watch}
checkValid={false}
checkMatch={{
Expand All @@ -71,12 +70,11 @@ export default function ChangeAdminPassword(props) {
}}
/>
<PasswordField
inputId="newPassword"
inputId="newAdminPassword"
name="newPassword"
label="Новий пароль"
error={errors}
register={register}
showError={true}
watch={watch}
checkValid={true}
checkMatch={{
Expand All @@ -85,7 +83,7 @@ export default function ChangeAdminPassword(props) {
}}
/>
<PasswordField
inputId="reNewPassword"
inputId="reNewAdminPassword"
name="reNewPassword"
label="Повторіть новий пароль"
error={errors}
Expand All @@ -97,7 +95,7 @@ export default function ChangeAdminPassword(props) {
checkWith: 'newPassword',
}}
/>
<AdminSubmitButton />
<AdminSubmitButton disabled={!isDirty}/>
</form>
) : (
<Loader />
Expand Down

0 comments on commit ca33389

Please sign in to comment.