Skip to content

Commit

Permalink
Add updateProfile mock function and change phone data
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarik-Popov committed Sep 22, 2024
1 parent 08cc656 commit 08701bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions gs/frontend/aro/src/profile/ProfileForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import { ProfileData } from "./profile-data";
import { useForm, SubmitHandler } from "react-hook-form";
import { updateProfile } from "./profile-api";

const ProfileForm = (props: ProfileData) => {
const [isEdit, setIsEdit] = useState(false);
Expand All @@ -14,6 +15,11 @@ const ProfileForm = (props: ProfileData) => {
const onSubmit: SubmitHandler<ProfileData> = (data: ProfileData) => {
console.log(data);
setIsEdit(false);
try {
updateProfile(data);
} catch (error) {
console.error(error);
}
};

// TODO: Add better error handling
Expand Down
11 changes: 10 additions & 1 deletion gs/frontend/aro/src/profile/profile-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export const getProfile = async (): Promise<ProfileData> => {
name: "John Doe",
email: "[email protected]",
call_sign: "VAYPO",
phone: "123-456-7890",
phone: "1234567890",
};
};

/**
* @brief Updates the profile info of the current user
* @param data The new profile data
*/
export const updateProfile = async (data: ProfileData): Promise<void> => {
// This is a mock implementation of an API call
console.log(data);
};

0 comments on commit 08701bb

Please sign in to comment.