"use server"; import { prisma, Prisma } from "@repo/db"; export const addMessage = async (message: Prisma.MessageCreateInput) => { try { // Set all current messages with isMainMsg=true to active=false await prisma.message.updateMany({ where: { isMainMsg: true }, data: { active: false }, }); await prisma.message.create({ data: { message: message.message, color: message.color, isMainMsg: true, active: true, showUntil: new Date().toISOString(), }, }); } catch (error) { throw new Error("Failed to add message"); } }; export const disableMessage = async () => { try { // Set all current messages with isMainMsg=true to active=false await prisma.message.updateMany({ where: { isMainMsg: true }, data: { active: false }, }); } catch (error) { throw new Error("Failed to disable message"); } };