updates
This commit is contained in:
@@ -53,23 +53,12 @@ const BannerCarousel: React.FC<BannerCarouselProps> = ({
|
||||
};
|
||||
|
||||
|
||||
const defaultBanner: Banner = {
|
||||
id: 0,
|
||||
title: 'Welcome to Hotel Booking',
|
||||
image_url: '/images/default-banner.jpg',
|
||||
position: 'home',
|
||||
display_order: 0,
|
||||
is_active: true,
|
||||
created_at: '',
|
||||
updated_at: '',
|
||||
description: undefined,
|
||||
link_url: undefined,
|
||||
};
|
||||
// Don't render if no banners - only show banners from API
|
||||
if (banners.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const displayBanners = banners.length > 0
|
||||
? banners
|
||||
: [defaultBanner];
|
||||
const currentBanner = displayBanners[currentIndex];
|
||||
const currentBanner = banners[currentIndex];
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -77,7 +66,7 @@ const BannerCarousel: React.FC<BannerCarouselProps> = ({
|
||||
>
|
||||
{}
|
||||
<div className="relative w-full h-full">
|
||||
{displayBanners.map((banner, index) => (
|
||||
{banners.map((banner, index) => (
|
||||
<div
|
||||
key={banner.id || index}
|
||||
className={`absolute inset-0 transition-opacity duration-1000 ease-in-out ${
|
||||
@@ -95,9 +84,6 @@ const BannerCarousel: React.FC<BannerCarouselProps> = ({
|
||||
src={banner.image_url}
|
||||
alt={banner.title}
|
||||
className="w-full h-full object-cover object-center transition-transform duration-1000 ease-out hover:scale-105"
|
||||
onError={(e) => {
|
||||
e.currentTarget.src = '/images/default-banner.jpg';
|
||||
}}
|
||||
/>
|
||||
</a>
|
||||
) : (
|
||||
@@ -105,9 +91,6 @@ const BannerCarousel: React.FC<BannerCarouselProps> = ({
|
||||
src={banner.image_url}
|
||||
alt={banner.title}
|
||||
className="w-full h-full object-cover object-center transition-transform duration-1000 ease-out hover:scale-105"
|
||||
onError={(e) => {
|
||||
e.currentTarget.src = '/images/default-banner.jpg';
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -272,7 +255,7 @@ const BannerCarousel: React.FC<BannerCarouselProps> = ({
|
||||
</div>
|
||||
|
||||
{}
|
||||
{displayBanners.length > 1 && (
|
||||
{banners.length > 1 && (
|
||||
<>
|
||||
<button
|
||||
onClick={goToPrevious}
|
||||
@@ -315,14 +298,14 @@ const BannerCarousel: React.FC<BannerCarouselProps> = ({
|
||||
)}
|
||||
|
||||
{}
|
||||
{displayBanners.length > 1 && (
|
||||
{banners.length > 1 && (
|
||||
<div
|
||||
className={`absolute left-1/2
|
||||
-translate-x-1/2 flex gap-2 sm:gap-2.5 z-40 pointer-events-auto
|
||||
bg-black/40 px-3 py-2 rounded-full
|
||||
border border-white/10 ${children ? 'bottom-16 sm:bottom-20 md:bottom-24 lg:bottom-28' : 'bottom-2 sm:bottom-4'}`}
|
||||
>
|
||||
{displayBanners.map((_, index) => (
|
||||
{banners.map((_, index) => (
|
||||
<button
|
||||
key={index}
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user