import { prisma } from "@repo/db";
import { MessageCircleWarning } from "lucide-react";

export const WarningAlert = async () => {
	const config = await prisma.config.findFirst({
		orderBy: [{ createdAt: "desc" }],
	});

	let msgColor;
	switch (config?.color) {
		case "WARNING":
			msgColor = "alert alert-soft alert-warning ml-3 py-2 flex items-center gap-2";
			break;
		case "INFO":
			msgColor = "alert alert-soft alert-info ml-3 py-2 flex items-center gap-2";
			break;
		case "SUCCESS":
			msgColor = "alert alert-soft alert-success ml-3 py-2 flex items-center gap-2";
			break;
		case "ERROR":
			msgColor = "alert alert-error ml-3 py-2 flex items-center gap-2";
			break;
		default:
			msgColor = "alert alert-soft ml-3 py-2 flex items-center gap-2";
	}

	if (config?.message || config?.maintenanceEnabled) {
		return (
			<div className={msgColor}>
				<MessageCircleWarning className="w-5 h-5" />
				{config?.message}
			</div>
		);
	}
};

/* ACHTUNG! Wir führen am kommenden Samstag Wartungsarbeiten am Server
				durch, von 19:00 Uhr bis 19:30 Uhr wird das HUB nicht erreichbar sein. */
