feat: Admin-Login-Button mit Umgebungsabhängiger Weiterleitung hinzugefügt
- Button zum Admin-Login im Header hinzugefügt, der abhängig von der Umgebung (`NODE_ENV`) zu "/login" (Entwicklung) oder "/login.html" (Produktion) weiterleitet - Tooltip "Als Admin anmelden" hinzugefügt, der angezeigt wird, wenn der Benutzer über den Admin-Button fährt - Icon für Admin-Login-Button mit `bi-person-circle` ergänzt für eine ansprechendere UI
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
"use client"; // components/Header.jsx
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/router";
|
||||
import "bootstrap-icons/font/bootstrap-icons.css";
|
||||
import SettingsModal from "./modales/settingsModal/SettingsModal";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
function Header() {
|
||||
const router = useRouter();
|
||||
const deviceName = useSelector((state) => state.variables.deviceName);
|
||||
const [cplStatus, setCplStatus] = useState("Lädt...");
|
||||
const [showSettingsModal, setShowSettingsModal] = useState(false);
|
||||
|
||||
const handleSettingsClick = () => setShowSettingsModal(true);
|
||||
const handleCloseSettingsModal = () => setShowSettingsModal(false);
|
||||
const handleLogout = () => (window.location.href = "/offline.html");
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Funktion zur Weiterleitung zur Login-Seite abhängig von der Umgebung
|
||||
const handleAdminLogin = () => {
|
||||
const loginPath =
|
||||
process.env.NODE_ENV === "production" ? "/login.html" : "/login";
|
||||
router.push(loginPath);
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="bg-gray-300 flex justify-between items-center w-full h-28 relative text-black">
|
||||
<div className="absolute left-32 top-32 transform -translate-y-1/2">
|
||||
@@ -44,7 +51,15 @@ function Header() {
|
||||
<i className="bi bi-gear"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex items-center justify-end w-full">
|
||||
<div className="flex items-center justify-end w-full space-x-2">
|
||||
<button
|
||||
onClick={handleAdminLogin}
|
||||
title="Als Admin anmelden"
|
||||
className="bg-littwin-blue text-white px-4 py-2 rounded flex items-center"
|
||||
>
|
||||
<i className="bi bi-person-circle mr-2"></i>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
className="bg-littwin-blue text-white px-4 py-2 rounded"
|
||||
|
||||
Reference in New Issue
Block a user