From 78bad074c71a6110ded7f2a847e88089c36a70f2 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 30 Aug 2022 21:22:41 -0600 Subject: [PATCH] password validate --- mobile-ui/components/Profile.js | 40 +++++++++++++++++++++++++-------- mobile-ui/package.json | 6 +++-- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index b4919616..59d261ac 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -9,6 +9,7 @@ import { UserContext } from "../context/UserContext"; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { stringMd5 } from 'react-native-quick-md5'; + const { Navigator, Screen } = createMaterialTopTabNavigator(); export default function Profile({ navigation }) { @@ -23,6 +24,7 @@ export default function Profile({ navigation }) { const userData = useContext(UserContext) const id = userData.user._id; const decode = userData.Password; + const [error, setError] = useState({}) console.log(userData.user); @@ -32,11 +34,15 @@ export default function Profile({ navigation }) { console.log(dpassword); - console.log(userData.password); - if (userData.password == dpassword) { + console.log(userData.user.password); + if (userData.user.password == dpassword) { console.log(true); }else{ console.log(false); + setError({ ...error, + + password: 'La contraseña no coincide con la actual' + }); } } @@ -115,21 +121,26 @@ export default function Profile({ navigation }) { Contraseña actual - onHandleChangePassword(value) }/> + onHandleChangePassword(value) }/> + Nueva Contraseña - setPassword(value) }/> + setPassword(value) } /> Confirmar nueva contraseña - setPassword(value) }/> + setPassword(value) }/> - + + {/* {'password' in error && La contraseña no coincide con la actual } */} @@ -202,18 +213,29 @@ export default function Profile({ navigation }) { const styles = StyleSheet.create({ input: { - height: 10, + height: 35, margin: 3, borderWidth: 0.5, padding: 5, flex: 1, paddingTop: 9, paddingRight: 19, - paddingBottom: 20, paddingLeft: 0, marginTop: 6, - marginBottom: 6, borderRadius: 4 + }, + errorMessage: { + height: 35, + margin: 3, + borderWidth: 0.5, + padding: 5, + flex: 1, + paddingTop: 9, + paddingRight: 19, + paddingLeft: 0, + marginTop: 6, + borderRadius: 4, + borderColor: '#be123c' } }) diff --git a/mobile-ui/package.json b/mobile-ui/package.json index 8576d722..b07de02d 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -14,7 +14,8 @@ "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", - "eject": "expo eject" + "eject": "expo eject", + "test" : "jest" }, "dependencies": { "@react-native-community/datetimepicker": "4.0.0", @@ -46,7 +47,8 @@ "universal-cookie": "^4.0.4" }, "devDependencies": { - "@babel/core": "^7.12.9" + "@babel/core": "^7.12.9", + "jest": "^29.0.1" }, "bugs": { "url": "https://github.com/GeekyAnts/nativebase-templates/issues"