Skip to content

Commit

Permalink
Add navigation to homepage after logout
Browse files Browse the repository at this point in the history
A `useNavigate` hook from react-router-dom has been added to the ProfilePage component. After a successful logout response, the user is now navigated back to the homepage.
  • Loading branch information
josch87 committed Jun 11, 2024
1 parent 1a43e6d commit 238fcb1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { UserType } from "../model/User.ts";
import axios from "axios";
import { logtail } from "../logger.ts";
import Button from "../components/Button/Button.tsx";
import { useNavigate } from "react-router-dom";

export default function ProfilePage() {
const navigate = useNavigate();

function login() {
const host =
window.location.host === "localhost:5173"
Expand All @@ -20,6 +23,7 @@ export default function ProfilePage() {
.get("/api/auth/logout")
.then(() => {
logtail.info("Logged out successfully");
navigate("/");
})
.catch((error) => {
logtail.error(error.message, {
Expand Down

0 comments on commit 238fcb1

Please sign in to comment.