Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ORG-69] Edit profile the endpoint is changed #72

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions organizator/app/(tabs)/profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export default function Index() {

const editProfile = () => {
setLoading(true);
updateMyInformation(inputs, userInformation?.id || "").then((response) => {

updateMyInformation(inputs, token || "").then((response) => {
if (response.error) {
setLoading(false);
Toast.show({
Expand All @@ -152,6 +153,12 @@ export default function Index() {
});
} else {
setLoading(false);
Toast.show({
type: "success",
text1: "Success",
text2: "Your profile has been updated correctly",
visibilityTime: 8000,
});
}
});
};
Expand Down Expand Up @@ -244,7 +251,7 @@ export default function Index() {
/>
<ButtonContainer>
<Button
title="Save"
title="Change information"
onPress={validate}
iconName="save"
color="#58a659"
Expand Down
7 changes: 5 additions & 2 deletions organizator/utils/api/axiosUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,20 @@ export async function getMyInformation(

export async function updateMyInformation(
data: UpdateFormFields,
id: string,
token: string,
): Promise<UserInformationResponse> {
try {
const response = await axios({
method: "post",
url: `${usersAPI}/update/${id}`,
url: `${usersAPI}/update/me`,
data: JSON.stringify({
first_name: data.firstName,
last_name: data.lastName,
bio: data.bio,
}),
headers: {
Authorization: token,
},
});
return {
error: null,
Expand Down