45 lines
1.5 KiB
React
45 lines
1.5 KiB
React
import React, { useEffect, useState } from "react";
|
|
import { Link } from "react-router-dom";
|
|
|
|
export default function HomeBannerOffersCard(props) {
|
|
const [imageUrl, setImageUrl] = useState("");
|
|
const link_result = "/" + props.itemData.link_path;
|
|
|
|
useEffect(() => {
|
|
let { banner, banner_location } = props?.itemData;
|
|
if (banner_location === "LOCAL") {
|
|
const imagePath = require(`../../assets/images/${banner}`); // Replace with your directory path for local images
|
|
setImageUrl(imagePath);
|
|
} else if (banner_location === "URL") setImageUrl(banner);
|
|
else return null;
|
|
}, []);
|
|
|
|
return (
|
|
<Link
|
|
to={link_result}
|
|
className="item w-full block group banner-630-340 bg-cover bg-center"
|
|
style={{
|
|
backgroundImage: `url('${imageUrl}')`,
|
|
}}
|
|
>
|
|
<div className="flex flex-col justify-between h-full">
|
|
<div className="content flex justify-between items-center mb-5">
|
|
<div className="siderCardHeader">
|
|
<h1 className="text-2xl font-bold text-dark-gray dark:text-white tracking-wide">
|
|
<span className="heroSilderTitle">{props.itemData.title}</span>
|
|
</h1>
|
|
</div>
|
|
</div>
|
|
<div className="h-[233px]">
|
|
<div className="siderCardDescription">
|
|
{props.itemData.description}
|
|
</div>
|
|
<div className="siderCardButton">
|
|
[ {props.itemData.button_text} ]
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Link>
|
|
);
|
|
}
|