From 7c050cf42eb697f15f8dd3aa1bd28cb337ab8332 Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Thu, 3 Jul 2025 21:17:23 -0700 Subject: [PATCH] =?UTF-8?q?Alter=20Maintenance-Screen=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/_components/navbar/PageAlert.tsx | 29 +++----- apps/dispatch/app/layout.tsx | 33 +++------ .../_components/MessageForm.tsx} | 65 +++++++----------- apps/hub/app/(app)/admin/config/action.tsx | 22 ++++++ .../(app)/admin/{message => config}/page.tsx | 36 +++------- apps/hub/app/(app)/admin/message/action.tsx | 39 ----------- apps/hub/app/_components/Nav.tsx | 2 +- apps/hub/app/_components/ui/PageAlert.tsx | 23 +++---- apps/hub/app/layout.tsx | 28 ++------ apps/hub/public/logo.png | Bin 0 -> 430263 bytes apps/hub/tsconfig.json | 2 +- .../migration.sql | 17 +++++ .../migration.sql | 8 +++ packages/database/prisma/schema/notam.prisma | 16 ++--- .../components/Maintenance.tsx | 46 +++++++++++++ .../shared-components/components/index.ts | 1 + 16 files changed, 168 insertions(+), 199 deletions(-) rename apps/hub/app/(app)/admin/{message/_components/messageForm.tsx => config/_components/MessageForm.tsx} (65%) create mode 100644 apps/hub/app/(app)/admin/config/action.tsx rename apps/hub/app/(app)/admin/{message => config}/page.tsx (63%) delete mode 100644 apps/hub/app/(app)/admin/message/action.tsx create mode 100644 apps/hub/public/logo.png create mode 100644 packages/database/prisma/schema/migrations/20250704024359_change_notal_fields/migration.sql create mode 100644 packages/database/prisma/schema/migrations/20250704024944_remove_show_until/migration.sql create mode 100644 packages/shared-components/components/Maintenance.tsx diff --git a/apps/dispatch/app/_components/navbar/PageAlert.tsx b/apps/dispatch/app/_components/navbar/PageAlert.tsx index d2f12840..df8927b9 100644 --- a/apps/dispatch/app/_components/navbar/PageAlert.tsx +++ b/apps/dispatch/app/_components/navbar/PageAlert.tsx @@ -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 ( -