Skip to content

Commit

Permalink
Profil updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Palutenya committed Jan 30, 2024
1 parent fd1eab6 commit b77fac3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion frontend/src/pages/Profil.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ function Profil() {
const handleEditClick = () => {
setEditing(true);
};

const handleKeepClick = () => {
axios
.get(`${import.meta.env.VITE_BACKEND_URL}/api/users/8`, {
withCredentials: true,
})
.then((res) => {
setUserData(res.data);
setEditing(false);
})
.catch((error) => {
console.error(error);
});
};

const handleSaveClick = () => {
axios
.put(
Expand Down Expand Up @@ -152,7 +167,9 @@ function Profil() {
<button
className="Edit"
type="button"
onClick={editing ? handleSaveClick : handleEditClick}
onClick={
editing ? handleSaveClick : handleKeepClick && handleEditClick
}
>
{editing ? "Save" : "Edit"}
</button>
Expand Down

0 comments on commit b77fac3

Please sign in to comment.