automatische environment für mockData in develop ,nach "npm run build" geht autoatisch zu production
This commit is contained in:
@@ -8,7 +8,6 @@ import SettingsModal from "./modales/SettingsModal";
|
||||
|
||||
function Header() {
|
||||
const [isClient, setIsClient] = useState(false);
|
||||
|
||||
const [stationsname, setStationsname] = useState("Lädt..."); // Platzhalter
|
||||
const [cplStatus, setCplStatus] = useState("Lädt...");
|
||||
const [showSettingsModal, setShowSettingsModal] = useState(false);
|
||||
@@ -26,13 +25,18 @@ function Header() {
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
window.location.href = "/offline.html"; // Opens offline.html
|
||||
window.location.href = "/offline.html"; // Öffnet offline.html
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
console.log("Lade Window-Variablen...");
|
||||
|
||||
loadWindowVariables()
|
||||
.then(() => {
|
||||
// Überprüfe, ob die erwarteten Variablen verfügbar sind
|
||||
console.log("Window-Variablen geladen:", window);
|
||||
|
||||
if (window.ip) {
|
||||
setStationsname(window.deviceName || "Unbekannt");
|
||||
setCplStatus(window.hardware_version || "Unbekannt");
|
||||
@@ -57,15 +61,17 @@ function Header() {
|
||||
"System.acp",
|
||||
];
|
||||
|
||||
const environment = process.env.NEXT_PUBLIC_NODE_ENV || "production"; // Fallback auf 'production'
|
||||
|
||||
files.forEach((file) => {
|
||||
const script = document.createElement("script");
|
||||
const environment = process.env.NODE_ENV;
|
||||
|
||||
if (environment === "production") {
|
||||
script.src = `/CPL?/CPL/SERVICE/${file}`; // Produktions-Pfad
|
||||
} else {
|
||||
script.src = `/CPL/CPL/SERVICE/${file}`; // Entwicklungs-Pfad
|
||||
script.src = `/mockData/${file}`; // Entwicklungs-Pfad
|
||||
}
|
||||
//script.src = `/CPL?/CPL/SERVICE/${file}`;
|
||||
|
||||
script.async = true;
|
||||
script.onload = () => console.log(`${file} wurde erfolgreich geladen.`);
|
||||
script.onerror = (error) =>
|
||||
@@ -75,7 +81,11 @@ function Header() {
|
||||
}
|
||||
}, [isClient]);
|
||||
|
||||
if (!isClient) return null; // Don't render the component until on the client side
|
||||
useEffect(() => {
|
||||
console.log("Environment:", process.env.NEXT_PUBLIC_NODE_ENV); // Logge die Umgebungsvariable
|
||||
}, []);
|
||||
|
||||
if (!isClient) return null; // Rendere die Komponente nicht, bis sie clientseitig ausgeführt wird
|
||||
|
||||
return (
|
||||
<header className="bg-gray-300 flex justify-between items-center w-full h-28 relative">
|
||||
@@ -94,7 +104,7 @@ function Header() {
|
||||
{/* CPL Status und Stationsname */}
|
||||
<div className="flex items-start space-x-4 w-full">
|
||||
<div className="flex flex-col text-left pl-8">
|
||||
<h2 className="text-base ">Stationsname</h2>
|
||||
<h2 className="text-base">Stationsname</h2>
|
||||
<p className="text-base text-gray-600">{stationsname}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user