From b117491db9738cb6c2171a427ed24adeed342694 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 30 Aug 2022 21:51:17 -0600 Subject: [PATCH] fix update profile --- mobile-ui/components/Profile.js | 62 ++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 59d261ac..dfe7e718 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -121,20 +121,20 @@ 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) }/> - @@ -152,22 +152,60 @@ export default function Profile({ navigation }) { const updatePassword = async() =>{ + const dataPassword = { + "_id": userData.user._id, + "dni": userData.user.dni, + "name": userData.user.name, + "last_name": userData.user.last_name, + "email": userData.user.email, + "phone": userData.user.phone, + "password": password, + "user_type": userData.user.user_type, + "status": userData.user.status, + "date_entry": userData.user.date_entry, + "community_id": userData.user.community_id, + } + + try { + + await fetch(baseURL+`${id}`, { + + cache: 'no-cache', + method: 'PUT', + body: JSON.stringify(dataPassword), + headers: { + 'Content-Type': 'application/json' + } + }) + .then(response => { + + console.log(baseURL+`${id}`); + if (response.status != 201){ + console.log('ocurrio un error '); + }else{ + return response.json(); + } + }) + + } catch (error) { + console.log("ERROR: " + error); + } } const updateInfo = async() => { const data = { - "_id": "6301df20dac7dcf76dcecade", - "dni": "1234567890", + "_id": userData.user._id, + "dni": userData.user.dni, "name": name, "last_name": apellido, "email": email, - "phone": 12121212, - "password": "827ccb0eea8a706c4c34a16891f84e7b", - "user_type": "3", - "status": "1", - "date_entry": "2022-08-21T07:30:09.929Z", - "community_id": null, + "phone": userData.user.phone, + "password": userData.user.password, + "user_type": userData.user.user_type, + "status": userData.user.status, + "date_entry": userData.user.date_entry, + "community_id": userData.user.community_id, } try {