import { prisma } from '@/lib/prisma';

export default async function PromotionBanner() {
  const now = new Date();
  const promotion = await prisma.promotion.findFirst({
    where: {
      AND: [
        { OR: [{ startsAt: null }, { startsAt: { lte: now } }] },
        { OR: [{ endsAt: null }, { endsAt: { gte: now } }] },
      ],
    },
    orderBy: { createdAt: 'desc' },
  });

  if (!promotion) return null;

  return (
    <div className="brand-gradient px-6 py-2 text-center text-sm font-medium text-white">
      {promotion.message}
    </div>
  );
}
