[오류 처리]
- 혹시 모를 남은 추천 수정한 파일들에 대한 수정. - 없을때는 빈배열이나 기초값으로 가도록 수정.
This commit is contained in:
@@ -85,30 +85,37 @@ const BestSeller = ({
|
|||||||
const [bestItemNewData, setBestItemNewData] = useState([]);
|
const [bestItemNewData, setBestItemNewData] = useState([]);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
setBestInfos(
|
setBestInfos(
|
||||||
bestSellerNewDatas?.filter(
|
bestSellerNewDatas?.filter(
|
||||||
(item) => item.recommendTpCd === "BESTSELLER"
|
(item) => item.recommendTpCd === "BESTSELLER"
|
||||||
)
|
) || [] // 기본값으로 빈 배열 설정
|
||||||
)
|
)
|
||||||
},[bestSellerNewDatas])
|
},[bestSellerNewDatas])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const recommendedData = bestInfos?.[0].productInfos?.slice(0, 2).map((item) => ({
|
if (!bestInfos || bestInfos.length === 0) {
|
||||||
...item,
|
const baseData = bestSellerDatas?.map((item) => ({
|
||||||
foryou: true,
|
...item,
|
||||||
})) || [];
|
foryou: false,
|
||||||
|
})) || [];
|
||||||
const recommendedPrdtIds = new Set(recommendedData.map(item => item.prdtId));
|
setBestItemNewData(baseData);
|
||||||
|
return;
|
||||||
const baseData = bestSellerDatas?.filter(
|
}
|
||||||
(item) => !recommendedPrdtIds.has(item.prdtId)
|
|
||||||
).map((item) => ({
|
const recommendedData = bestInfos[0].productInfos?.slice(0, 20).map((item) => ({
|
||||||
...item,
|
...item,
|
||||||
foryou: false,
|
foryou: true,
|
||||||
})) || [];
|
})) || [];
|
||||||
|
|
||||||
setBestItemNewData([...recommendedData, ...baseData]);
|
const recommendedPrdtIds = new Set(recommendedData.map(item => item.prdtId));
|
||||||
}, [bestSellerDatas, bestInfos?.[0].productInfos]);
|
|
||||||
|
const baseData = bestSellerDatas?.map((item) => ({
|
||||||
|
...item,
|
||||||
|
foryou: recommendedPrdtIds.has(item.prdtId),
|
||||||
|
})) || [];
|
||||||
|
|
||||||
|
setBestItemNewData(baseData);
|
||||||
|
}, [bestSellerDatas, bestInfos]);
|
||||||
|
|
||||||
const orderStyle = useMemo(() => ({ order: order }), [order]);
|
const orderStyle = useMemo(() => ({ order: order }), [order]);
|
||||||
|
|
||||||
@@ -286,7 +293,7 @@ const BestSeller = ({
|
|||||||
offerInfo={offerInfo}
|
offerInfo={offerInfo}
|
||||||
spotlightId={"bestsellerItem" + itemIndex}
|
spotlightId={"bestsellerItem" + itemIndex}
|
||||||
firstLabel={rankText}
|
firstLabel={rankText}
|
||||||
label={itemIndex * 1 + 1 + " of " + bestInfos?.[0].productInfos.length}
|
label={itemIndex * 1 + 1 + " of " + bestItemNewData.length}
|
||||||
lastLabel=" go to detail, button"
|
lastLabel=" go to detail, button"
|
||||||
euEnrgLblInfos={euEnrgLblInfos}
|
euEnrgLblInfos={euEnrgLblInfos}
|
||||||
>
|
>
|
||||||
@@ -311,4 +318,4 @@ const BestSeller = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BestSeller;
|
export default BestSeller;
|
||||||
@@ -121,7 +121,7 @@ export default memo(function SubCategory({
|
|||||||
}
|
}
|
||||||
setDrawChk(true);
|
setDrawChk(true);
|
||||||
}
|
}
|
||||||
}, [currentLgCatCd, dispatch]);
|
}, [currentLgCatCd, dispatch, firstChk]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!nowMenuRef.current || !nowMenuRef.current.startsWith("Home")) {
|
if (!nowMenuRef.current || !nowMenuRef.current.startsWith("Home")) {
|
||||||
@@ -138,7 +138,7 @@ export default memo(function SubCategory({
|
|||||||
|
|
||||||
dispatch(sendLogCuration(params));
|
dispatch(sendLogCuration(params));
|
||||||
}
|
}
|
||||||
}, [categoryInfos, currentLgCatCd, currentLgCatNm]);
|
}, [categoryInfos, currentLgCatCd, currentLgCatNm, dispatch, nowMenuRef]);
|
||||||
|
|
||||||
const handleCategoryNav = useCallback(
|
const handleCategoryNav = useCallback(
|
||||||
(lgCatCd, lgCatNm) => {
|
(lgCatCd, lgCatNm) => {
|
||||||
@@ -153,7 +153,7 @@ export default memo(function SubCategory({
|
|||||||
|
|
||||||
setContainerLastFocusedElement(null, [SpotlightIds.HOME_CATEGORY_NAV]);
|
setContainerLastFocusedElement(null, [SpotlightIds.HOME_CATEGORY_NAV]);
|
||||||
},
|
},
|
||||||
[currentLgCatCd]
|
[currentLgCatCd, handleScrollReset]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleFocus = useCallback(
|
const handleFocus = useCallback(
|
||||||
@@ -164,7 +164,7 @@ export default memo(function SubCategory({
|
|||||||
handleScrollReset();
|
handleScrollReset();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[_handleItemFocus]
|
[_handleItemFocus, handleScrollReset]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleBlur = useCallback(
|
const handleBlur = useCallback(
|
||||||
@@ -173,7 +173,7 @@ export default memo(function SubCategory({
|
|||||||
handleStopScrolling();
|
handleStopScrolling();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[]
|
[handleStopScrolling]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleCardClick = useCallback(
|
const handleCardClick = useCallback(
|
||||||
@@ -185,7 +185,7 @@ export default memo(function SubCategory({
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[]
|
[dispatch, spotlightId]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleScrollRight = useCallback((e) => {
|
const handleScrollRight = useCallback((e) => {
|
||||||
@@ -193,7 +193,7 @@ export default memo(function SubCategory({
|
|||||||
const x = container.scrollWidth - container.clientWidth;
|
const x = container.scrollWidth - container.clientWidth;
|
||||||
|
|
||||||
setTimeout(() => scrollLeft({ x, animate: true }));
|
setTimeout(() => scrollLeft({ x, animate: true }));
|
||||||
}, []);
|
}, [scrollLeft]);
|
||||||
|
|
||||||
const handleMoreCardClick = useCallback((e) => {
|
const handleMoreCardClick = useCallback((e) => {
|
||||||
const lgCatCd = e.currentTarget?.getAttribute("data-catcd-num");
|
const lgCatCd = e.currentTarget?.getAttribute("data-catcd-num");
|
||||||
@@ -212,7 +212,7 @@ export default memo(function SubCategory({
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [dispatch]);
|
||||||
|
|
||||||
const _handleItemFocus = useCallback(() => {
|
const _handleItemFocus = useCallback(() => {
|
||||||
if (handleItemFocus) {
|
if (handleItemFocus) {
|
||||||
@@ -227,7 +227,16 @@ export default memo(function SubCategory({
|
|||||||
}, [handleShelfFocus]);
|
}, [handleShelfFocus]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const recommendedData = foruItemInfos?.slice(0, 2).map((item) => ({
|
if (!foruItemInfos || foruItemInfos.length === 0) {
|
||||||
|
const baseData = categoryItemInfos?.subCatItemList?.map((item) => ({
|
||||||
|
...item,
|
||||||
|
foryou: false,
|
||||||
|
})) || [];
|
||||||
|
setCategoryItemNewData(baseData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recommendedData = foruItemInfos?.slice(0, 10).map((item) => ({
|
||||||
...item,
|
...item,
|
||||||
foryou: true,
|
foryou: true,
|
||||||
})) || [];
|
})) || [];
|
||||||
@@ -267,59 +276,6 @@ export default memo(function SubCategory({
|
|||||||
cbScrollTo={getScrollTo}
|
cbScrollTo={getScrollTo}
|
||||||
noScrollByWheel
|
noScrollByWheel
|
||||||
>
|
>
|
||||||
{/* {categoryItemInfos &&
|
|
||||||
categoryItemInfos?.subCatItemList.map(
|
|
||||||
(
|
|
||||||
{
|
|
||||||
prdtId,
|
|
||||||
imgUrl,
|
|
||||||
priceInfo,
|
|
||||||
prdtNm,
|
|
||||||
patnrId,
|
|
||||||
offerInfo,
|
|
||||||
brndNm,
|
|
||||||
patncNm,
|
|
||||||
},
|
|
||||||
itemIndex
|
|
||||||
) => {
|
|
||||||
return (
|
|
||||||
<TItemCardNew
|
|
||||||
key={"subItem" + itemIndex}
|
|
||||||
contextName={LOG_CONTEXT_NAME.HOME}
|
|
||||||
messageId={LOG_MESSAGE_ID.SHELF_CLICK}
|
|
||||||
catNm={categoryItemInfos.catNm}
|
|
||||||
order={itemIndex + 1}
|
|
||||||
shelfId={spotlightId}
|
|
||||||
shelfLocation={shelfLocation}
|
|
||||||
shelfTitle={shelfTitle}
|
|
||||||
brandName={brndNm}
|
|
||||||
patnerName={patncNm}
|
|
||||||
imageAlt={prdtId}
|
|
||||||
imageSource={imgUrl}
|
|
||||||
priceInfo={priceInfo}
|
|
||||||
productName={prdtNm}
|
|
||||||
productId={prdtId}
|
|
||||||
onFocus={handleFocus(itemIndex)}
|
|
||||||
onBlur={handleBlur(itemIndex)}
|
|
||||||
onClick={handleCardClick(patnrId, prdtId)}
|
|
||||||
offerInfo={offerInfo}
|
|
||||||
data-catcd-num={currentLgCatCd}
|
|
||||||
data-catcd-nm={currentLgCatNm}
|
|
||||||
label={
|
|
||||||
itemIndex * 1 +
|
|
||||||
1 +
|
|
||||||
" of " +
|
|
||||||
categoryItemInfos?.subCatItemList.length
|
|
||||||
}
|
|
||||||
lastLabel=" go to detail, button"
|
|
||||||
>
|
|
||||||
|
|
||||||
<Tag text={"For You"} />
|
|
||||||
|
|
||||||
</TItemCardNew>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)} 원본 보관*/}
|
|
||||||
{categoryItemNewData &&
|
{categoryItemNewData &&
|
||||||
categoryItemNewData.slice(0, 10).map(
|
categoryItemNewData.slice(0, 10).map(
|
||||||
(
|
(
|
||||||
@@ -342,7 +298,7 @@ export default memo(function SubCategory({
|
|||||||
key={"subItem" + itemIndex}
|
key={"subItem" + itemIndex}
|
||||||
contextName={LOG_CONTEXT_NAME.HOME}
|
contextName={LOG_CONTEXT_NAME.HOME}
|
||||||
messageId={LOG_MESSAGE_ID.SHELF_CLICK}
|
messageId={LOG_MESSAGE_ID.SHELF_CLICK}
|
||||||
catNm={categoryItemInfos.catNm}
|
catNm={categoryItemInfos?.catNm}
|
||||||
order={itemIndex + 1}
|
order={itemIndex + 1}
|
||||||
shelfId={spotlightId}
|
shelfId={spotlightId}
|
||||||
shelfLocation={shelfLocation}
|
shelfLocation={shelfLocation}
|
||||||
@@ -364,7 +320,7 @@ export default memo(function SubCategory({
|
|||||||
itemIndex * 1 +
|
itemIndex * 1 +
|
||||||
1 +
|
1 +
|
||||||
" of " +
|
" of " +
|
||||||
categoryItemInfos?.subCatItemList.length
|
(categoryItemNewData?.length || 0)
|
||||||
}
|
}
|
||||||
lastLabel=" go to detail, button"
|
lastLabel=" go to detail, button"
|
||||||
euEnrgLblInfos={euEnrgLblInfos}
|
euEnrgLblInfos={euEnrgLblInfos}
|
||||||
@@ -391,4 +347,4 @@ export default memo(function SubCategory({
|
|||||||
</ContainerBasic>
|
</ContainerBasic>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user