fix user profile button disabled status

This commit is contained in:
2022-06-12 18:00:58 +08:00
parent 4fcd962cc9
commit d7b6b3849c

View File

@@ -9,11 +9,11 @@ function UserProfile(props) {
const [newPassword, setNewPassword] = useState(""); const [newPassword, setNewPassword] = useState("");
const [newPasswordConfirm, setNewPasswordConfirm] = useState(""); const [newPasswordConfirm, setNewPasswordConfirm] = useState("");
const [user, setUser] = useState({ const [user, setUser] = useState({
id: "", id: 0,
username: "", username: "",
role: "", role: 0,
active: "", active: false,
avatar_id: "", avatar_id: 0,
}); });
function getReviews() { function getReviews() {
@@ -101,7 +101,7 @@ function UserProfile(props) {
} }
}); });
}} }}
disabled={props.user.id !== user.id || props.user.role === 1} disabled={props.user.id !== user.id && props.user.role !== 1}
> >
Save Username Save Username
</button> </button>
@@ -149,9 +149,9 @@ function UserProfile(props) {
}); });
}} }}
disabled={ disabled={
(props.user.id !== user.id || (props.user.id !== user.id && props.user.role !== 1) ||
props.user.role !== 1) && newPassword !== newPasswordConfirm ||
newPassword !== newPasswordConfirm newPassword.length === 0
} }
> >
Change Password Change Password