From 238fcb1548800759eed5b086161806ea6461c229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljoscha=20Z=C3=B6ller?= Date: Tue, 11 Jun 2024 17:11:35 +0200 Subject: [PATCH] Add navigation to homepage after logout 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. --- frontend/src/pages/ProfilePage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/pages/ProfilePage.tsx b/frontend/src/pages/ProfilePage.tsx index cfa2ca2..0002f6f 100644 --- a/frontend/src/pages/ProfilePage.tsx +++ b/frontend/src/pages/ProfilePage.tsx @@ -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" @@ -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, {