Added improved login and logout route for the frontend. The frontend page now doesn't have to reload.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import React from "react";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const Header: React.FC = () => {
|
||||
type HeaderProps = {
|
||||
onLogout: () => void;
|
||||
};
|
||||
|
||||
const Header: React.FC<HeaderProps> = ({ onLogout }) => {
|
||||
return (
|
||||
<header className="mb-6 md:mb-10">
|
||||
<h1 className="text-3xl md:text-4xl font-extrabold text-blue-800 tracking-tight drop-shadow-sm">
|
||||
@@ -11,12 +14,8 @@ const Header: React.FC = () => {
|
||||
Schnell und unkompliziert Equipment reservieren
|
||||
</p>
|
||||
<button
|
||||
onClick={() => {
|
||||
Cookies.remove("token");
|
||||
localStorage.removeItem("allItems");
|
||||
|
||||
window.location.reload();
|
||||
}}
|
||||
type="button"
|
||||
onClick={onLogout}
|
||||
className="text-blue-500 hover:underline"
|
||||
>
|
||||
Logout
|
||||
|
Reference in New Issue
Block a user