43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import React, {
|
|
useEffect,
|
|
useState,
|
|
} from 'react';
|
|
|
|
import HomeTodayDeal from '../HomeTodayDeal/HomeTodayDeal';
|
|
|
|
export default function RandomUnit({ bannerData, imageType }) {
|
|
const bannerDetailInfos = bannerData.bannerDetailInfos;
|
|
const [randomData, setRandomData] = useState([]);
|
|
|
|
useEffect(() => {
|
|
if (bannerData) {
|
|
const leng = bannerData.bannerDetailInfos.length;
|
|
const num = Math.floor(Math.random() * leng);
|
|
setRandomData(bannerDetailInfos[num]);
|
|
}
|
|
}, [bannerData]);
|
|
|
|
return (
|
|
<>
|
|
{randomData.shptmBanrTpNm == "Image Banner" ? (
|
|
<p>TEST</p>
|
|
) : randomData.shptmBanrTpNm == "LIVE" ||
|
|
randomData.shptmBanrTpNm == "VOD" ? (
|
|
<p>비디오</p>
|
|
) : randomData.shptmBanrTpNm == "Today's Deals" ||
|
|
randomData.shptmBanrTpNm == "" ? (
|
|
<HomeTodayDeal
|
|
imgAlt={randomData.imgAlt}
|
|
imageName={randomData.tmnlImgNm}
|
|
imgPath={randomData.tmnlImgPath}
|
|
priceInfo={randomData.priceInfo}
|
|
productId={randomData.prdtId}
|
|
productName={randomData.prdtNm}
|
|
soldoutFlag={randomData.soldoutFlag}
|
|
isHorizontal={imageType}
|
|
/>
|
|
) : null}
|
|
</>
|
|
);
|
|
}
|