Alter Maintenance-Screen hinzugefügt

This commit is contained in:
PxlLoewe
2025-07-03 21:17:23 -07:00
parent 2ff2c3274a
commit 7c050cf42e
16 changed files with 168 additions and 199 deletions

View File

@@ -1,22 +1,13 @@
import { prisma } from "@repo/db";
import { MessageCircleWarning } from "lucide-react";
const fetchMainMessage = async () => {
return await prisma.notam.findFirst({
where: {
active: true,
},
});
};
export const WarningAlert = async () => {
const mainMessage = await fetchMainMessage();
if (mainMessage?.showUntilActive && new Date(mainMessage.showUntil) < new Date()) {
return <></>;
}
const config = await prisma.notam.findFirst({
orderBy: [{ createdAt: "desc" }],
});
let msgColor;
switch (mainMessage?.color) {
switch (config?.color) {
case "WARNING":
msgColor = "alert alert-soft alert-warning ml-3 py-2 flex items-center gap-2";
break;
@@ -33,15 +24,11 @@ export const WarningAlert = async () => {
msgColor = "alert alert-soft ml-3 py-2 flex items-center gap-2";
}
if ((mainMessage?.message == "" && !mainMessage?.wartungsmodus) || !mainMessage) {
return <></>;
} else {
if (config?.message || config?.maintenanceEnabled) {
return (
<div role="alert" className={msgColor}>
<MessageCircleWarning />
<span className="font-bold m-0">
{mainMessage?.wartungsmodus ? "Wartungsmodus aktiv!" : mainMessage?.message}
</span>
<div className={msgColor}>
<MessageCircleWarning className="w-5 h-5" />
{config?.message}
</div>
);
}