/* eslint-disable @next/next/no-img-element */ "use client"; import React from "react"; import Link from "next/link"; import { Banner } from "../lib/types"; interface BannerPlacementProps { banners: Banner[]; position: "home_middle" | "home_bottom" | "shop_top" | "category_top" | "product_sidebar"; className?: string; } export default function BannerPlacement({ banners, position, className = "", }: BannerPlacementProps) { const filteredBanners = (banners || []).filter( (b) => b.position === position && b.isActive !== false && b.imageUrl ); if (!filteredBanners || filteredBanners.length === 0) { return null; } // Multi-column layout for home_middle if 2 or more banners exist if (position === "home_middle") { return (
1 ? "grid-cols-1 md:grid-cols-2" : "grid-cols-1" }`} > {filteredBanners.map((banner) => { const cardContent = (
{banner.title {(banner.title || banner.subtitle) && (
{banner.title && (

{banner.title}

)} {banner.subtitle && (

{banner.subtitle}

)}
)}
); if (banner.linkUrl) { const isExternal = banner.linkUrl.startsWith("http"); if (isExternal) { return ( {cardContent} ); } return ( {cardContent} ); } return
{cardContent}
; })}
); } // Wide banner layout for home_bottom and shop_top if (position === "home_bottom" || position === "shop_top" || position === "category_top") { return (
{filteredBanners.map((banner) => { const cardContent = (
{banner.title {(banner.title || banner.subtitle) && (
{banner.title && (

{banner.title}

)} {banner.subtitle && (

{banner.subtitle}

)}
)}
); if (banner.linkUrl) { const isExternal = banner.linkUrl.startsWith("http"); if (isExternal) { return ( {cardContent} ); } return ( {cardContent} ); } return
{cardContent}
; })}
); } // Sidebar Banner Layout return (
{filteredBanners.map((banner) => { const cardContent = (
{banner.title {banner.title && (
{banner.title}
)}
); if (banner.linkUrl) { const isExternal = banner.linkUrl.startsWith("http"); if (isExternal) { return ( {cardContent} ); } return ( {cardContent} ); } return
{cardContent}
; })}
); }