Fix updating profile on app

This commit is contained in:
Adolfo Reyna
2025-02-10 21:44:37 -05:00
parent a85d9779b8
commit fce958fbfc

View File

@@ -20,6 +20,7 @@ let ProfileSettings = ()=>{
const [name, setName] = React.useState(viewer.profile.firstName);
const [lastName, setLastName] = React.useState(viewer.profile.lastName);
const [photoUrl, setphotoUrl] = React.useState(viewer.profile.photo);
const [language, setLanguage] = React.useState(viewer.profile.language);
const [updateKey, setUpdateKey] = React.useState(0);
const [description, setDescription] = React.useState(viewer.profile.description);
const [uploading, setUploading] = React.useState(false);
@@ -88,11 +89,26 @@ let ProfileSettings = ()=>{
return uploadedFile;
};
let updateProfile = () => {
GlobalState.me.profile.firstName = name;
GlobalState.me.profile.lastName = lastName;
GlobalState.me.profile.description = description;
API.updateMyProfile(GlobalState.me.profile, viewer.data);
let updateProfile = async () => {
let currentProfile = await API.getUserProfile(viewer._id)
currentData = currentProfile.data;
currentProfile = currentProfile.profile;
try {
//let currentProfile = JSON.parse(JSON.stringify(viewer.profile));
currentProfile.firstName = name;
currentProfile.lastName = lastName;
currentProfile.description = description;
currentProfile.language = language;
currentProfile.photo = photoUrl;
console.log("updating", currentProfile);
} catch (error) {
alert("Error updating profile, contact administrator.");
return;
}
let r = await API.updateMyProfile(currentProfile, currentData).catch((e) => {
alert("Error updating profile, contact administrator.");
});
console.log(r);
setUpdateKey(updateKey + 1);
}
@@ -129,9 +145,11 @@ let ProfileSettings = ()=>{
/>
<Text>Language:</Text>
<View style={{ flexDirection: "row" }}>
<RadioButton.Group value='en' style={{flexDirection:"row"}}>
<RadioButton.Group value={language} onValueChange={setLanguage} style={{ flexDirection: "row" }}>
<RadioButton.Item value="es" label="Español" />
<RadioButton.Item value="en" label="English" />
<RadioButton.Item value="da" label="Danish" />
<RadioButton.Item value="fr" label="French" />
</RadioButton.Group>
</View>
<Button icon="photo" mode="outlined" onPress={pickImage}>{!uploading ? i18n.t("message.updatePhoto") : "uploading"}</Button>