1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

clearing initial data on settings

This commit is contained in:
Fedor Katurov 2019-11-14 15:11:25 +07:00
parent 93e7b05ddf
commit d8d7f6e035

View file

@ -19,7 +19,8 @@ const mapStateToProps = state => ({
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
authPatchUser: AUTH_ACTIONS.authPatchUser authPatchUser: AUTH_ACTIONS.authPatchUser,
authSetProfile: AUTH_ACTIONS.authSetProfile
}; };
type IProps = ReturnType<typeof mapStateToProps> & type IProps = ReturnType<typeof mapStateToProps> &
@ -27,8 +28,9 @@ type IProps = ReturnType<typeof mapStateToProps> &
const ProfileSettingsUnconnected: FC<IProps> = ({ const ProfileSettingsUnconnected: FC<IProps> = ({
user, user,
profile: { patch_errors },
authPatchUser, authPatchUser,
profile: { patch_errors } authSetProfile
}) => { }) => {
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [new_password, setNewPassword] = useState(""); const [new_password, setNewPassword] = useState("");
@ -44,6 +46,7 @@ const ProfileSettingsUnconnected: FC<IProps> = ({
data, data,
setData setData
]); ]);
const setUsername = useCallback(username => setData({ ...data, username }), [ const setUsername = useCallback(username => setData({ ...data, username }), [
data, data,
setData setData
@ -68,6 +71,10 @@ const ProfileSettingsUnconnected: FC<IProps> = ({
[data, password, new_password, authPatchUser] [data, password, new_password, authPatchUser]
); );
useEffect(() => {
authSetProfile({ patch_errors: {} });
}, [password, new_password, data]);
return ( return (
<form className={styles.wrap} onSubmit={onSubmit}> <form className={styles.wrap} onSubmit={onSubmit}>
<Group> <Group>