all repos — caroster @ d348bb220acff865c19ce44aaad20f7ee9f92067

[Octree] Group carpool to your event https://caroster.io

change password flow, profile buttons ui
Karian Før karian.for@gmail.com
Wed, 22 Jul 2020 11:21:32 +0200
commit

d348bb220acff865c19ce44aaad20f7ee9f92067

parent

4a0142c40fa8f7d43889465908667617995be6bc

3 files changed, 14 insertions(+), 25 deletions(-)

jump to
M app/src/containers/Profile/EditPassword.jsapp/src/containers/Profile/EditPassword.js

@@ -34,10 +34,10 @@ title={t('profile.actions.change_password')}

action={ <IconButton color="inherit" - edge="end" id="ChangePasswordAction" type="submit" title={t('profile.actions.save')} + disabled={oldPassword.length < 4 || newPassword.length < 4} > <Icon>done</Icon> </IconButton>

@@ -69,19 +69,12 @@ name="new_password"

/> </CardContent> <CardActions> - <Button - type="button" - color="secondary" - size="small" - variant="contained" - onClick={cancel} - > + <Button type="button" onClick={cancel}> {t('profile.actions.cancel')} </Button> <Button type="submit" color="primary" - size="small" variant="contained" disabled={oldPassword.length < 4 || newPassword.length < 4} >
M app/src/containers/Profile/index.jsapp/src/containers/Profile/index.js

@@ -25,6 +25,13 @@ const [oldPassword, setOldPassword] = useState('');

const [newPassword, setNewPassword] = useState(''); const [errorPassword, setErrorPassword] = useState(''); + const resetPassword = () => { + setIsEditingPassword(false); + setNewPassword(''); + setOldPassword(''); + setErrorPassword(''); + }; + const savePassword = async () => { try { await updateProfile({

@@ -32,13 +39,13 @@ old_password: oldPassword,

password: newPassword, }); addToast(t('profile.password_changed')); + resetPassword(); } catch (err) { if (err.kind === 'bad_data') { setErrorPassword(t('profile.errors.password_nomatch')); return; } } - setIsEditingPassword(false); }; if (isEditingPassword)

@@ -50,11 +57,7 @@ setOldPassword={setOldPassword}

setNewPassword={setNewPassword} error={errorPassword} save={savePassword} - cancel={() => { - setIsEditingPassword(false); - setNewPassword(''); - setOldPassword(''); - }} + cancel={resetPassword} /> );

@@ -79,7 +82,6 @@ <CardHeader

action={ <IconButton color="inherit" - edge="end" id="EditProfileAction" type="submit" title={

@@ -130,7 +132,6 @@ {isEditing && (

<Button type="button" color="primary" - size="small" onClick={evt => { if (evt.preventDefault) evt.preventDefault(); setIsEditingPassword(true);

@@ -140,12 +141,7 @@ {t('profile.actions.change_password')}

</Button> )} {!isEditing && ( - <Button - type="button" - color="secondary" - size="small" - onClick={() => logout()} - > + <Button type="button" color="default" onClick={() => logout()}> {t('profile.actions.logout')} </Button> )}
M app/src/theme.jsapp/src/theme.js

@@ -6,10 +6,10 @@ primary: {

main: '#009688', }, secondary: { - main: '#ffde03', + main: '#FFEB3B', }, background: { - default: '#f4f4ff', + default: '#F4F4FF', }, }, mixins: {