[categoryPanel] 아이템 카드, 결과 없을 시 노출 view 구현

This commit is contained in:
hyunwoo93.cha
2024-02-16 16:22:00 +09:00
parent 0404528b93
commit b26dea0f13
9 changed files with 246 additions and 26 deletions

View File

@@ -1,5 +1,88 @@
import React from "react"; import React, { useCallback } from "react";
import { useSelector } from "react-redux";
import { VirtualGridList } from "@enact/sandstone/VirtualList";
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
import TItemCard from "../../../../components/TItemCard/TItemCard";
import { scaleH, scaleW } from "../../../../utils/helperMethods";
import NoResultsCategoryItems from "../NoResultsCategory/NoResultsCategoryItems";
import css from "./ItemContents.module.less";
const LIST_ITEM_CONF = {
ITEM_WIDTH: 324,
ITEM_HEIGHT: 438,
SPACING: 18,
};
const Container = SpotlightContainerDecorator(
{ enterTo: "last-focused" },
"div"
);
export default function ItemContents() { export default function ItemContents() {
return <p>ITEM</p>; const itemListDatas = useSelector(
(state) => state.main.subCategoryData?.categoryItemInfos
);
const renderItem = useCallback(
({ index, ...rest }) => {
const itemInfo = itemListDatas[index];
const {
catNm,
cntryCd,
imgUrl,
lgCatCd,
offerInfo,
patncLogoPath,
patnrId,
prdtId,
prdtNm,
priceInfo,
rankOrd,
total,
} = itemInfo;
return (
<TItemCard
{...rest}
key={prdtId}
imageAlt={prdtId}
imageSource={imgUrl}
priceInfo={priceInfo}
productName={prdtNm}
/>
);
},
[itemListDatas]
);
return (
<>
<div>
<Container className={css.container}>
{itemListDatas && itemListDatas.length > 0 && (
<VirtualGridList
className={css.grid}
dataSize={itemListDatas.length}
direction="vertical"
verticalScrollbar="hidden"
itemRenderer={renderItem}
itemSize={{
minWidth: scaleW(LIST_ITEM_CONF.ITEM_WIDTH),
minHeight: scaleH(LIST_ITEM_CONF.ITEM_HEIGHT),
}}
noScrollByWheel
scrollMode="translate"
spacing={scaleW(LIST_ITEM_CONF.SPACING)}
/>
)}
{itemListDatas && itemListDatas.length === 0 && (
<NoResultsCategoryItems />
)}
</Container>
</div>
</>
);
} }

View File

@@ -0,0 +1,15 @@
@import "../../../../style/CommonStyle.module.less";
@import "../../../../style/utils.module.less";
.container {
.size(@w: 100%, @h: auto);
margin-top: 34px;
.grid {
overflow: unset;
> div {
overflow: unset !important;
}
}
}

View File

@@ -0,0 +1,46 @@
import React from "react";
import { useSelector } from "react-redux";
import NoResultsImage from "../../../../../assets/searchpanel/img-search-nodata.png";
import SectionTitle from "../../../../components/SectionTitle/SectionTitle";
import TGrid from "../../../../components/TGrid/TGrid";
import TItemCard from "../../../../components/TItemCard/TItemCard";
import { $L } from "../../../../utils/helperMethods";
import css from "./NoResultsCategoryItems.module.less";
export default function NoResultsCategoryItems() {
const bestSellerDatas = useSelector(
(state) => state.product.bestSellerData.bestSeller
);
return (
<div className={css.container}>
<div className={css.info}>
<div className={css.imageBox}>
<img src={NoResultsImage} alt="No Datas" />
</div>
<p>{$L("THERE ARE NO ITEMS AVAILABLE")}</p>
</div>
<div className={css.bestSellerWrap}>
<SectionTitle title={$L("BEST SELLER")} />
<TGrid>
{bestSellerDatas &&
bestSellerDatas
.slice(0, 5)
.map((bestSeller) => (
<TItemCard
key={bestSeller.rankOrd}
imageSource={bestSeller.imgUrl}
imageAlt={bestSeller.prdtNm}
productName={bestSeller.prdtNm}
priceInfo={bestSeller.priceInfo}
rank={bestSeller.rankOrd}
isBestSeller
/>
))}
</TGrid>
</div>
</div>
);
}

View File

@@ -0,0 +1,35 @@
@import "../../../../style/CommonStyle.module.less";
@import "../../../../style/utils.module.less";
.container {
margin-top: 100px;
.info {
text-align: center;
.imageBox {
.size(@w: 360px, @h: 180px);
margin: 0 auto;
background-size: cover;
> img {
object-fit: cover;
.size(@w: 100%, @h: 100%);
}
}
> p {
.font (@fontFamily: @baseFontBold, @fontSize: 36px);
color: #a3a3a3;
margin-top: 6px;
}
}
.bestSellerWrap {
padding: 60px 60px 78px 0;
> h2 {
margin: 134px 0 34px;
}
}
}

View File

@@ -0,0 +1,26 @@
@import "../../../../style/CommonStyle.module.less";
@import "../../../../style/utils.module.less";
.container {
margin-top: 100px;
.info {
text-align: center;
.imageBox {
.size(@w: 360px, @h: 180px);
margin: 0 auto;
background-size: cover;
> img {
object-fit: cover;
.size(@w: 100%, @h: 100%);
}
}
}
.popularShowWrap {
margin-left: -60px;
padding-bottom: 60px;
}
}

View File

@@ -0,0 +1,22 @@
import React from "react";
import NoResultsImage from "../../../../../assets/searchpanel/img-search-nodata.png";
import { $L } from "../../../../utils/helperMethods";
import PopularShow from "../../../HomePanel/PopularShow/PopularShow";
import css from "./NoResultsCategoryShow.module.less";
export default function NoResultsCategoryShows() {
return (
<div className={css.container}>
<div className={css.info}>
<div className={css.imageBox}>
<img src={NoResultsImage} alt="No Datas" />
</div>
<p>{$L("THERE ARE NO SHOWS AVAILABLE")}</p>
</div>
<div className={css.popularShowWrap}>
<PopularShow />
</div>
</div>
);
}

View File

@@ -4,6 +4,7 @@ import { useSelector } from "react-redux";
import Spottable from "@enact/spotlight/Spottable"; import Spottable from "@enact/spotlight/Spottable";
import NoResultsCategoryShows from "../NoResultsCategory/NoResultsCategoryShows";
import css from "./ShowContents.module.less"; import css from "./ShowContents.module.less";
import ShowLists from "./ShowLists/ShowLists"; import ShowLists from "./ShowLists/ShowLists";
import ShowProductContents from "./ShowProductContents/ShowProductContents"; import ShowProductContents from "./ShowProductContents/ShowProductContents";
@@ -15,8 +16,6 @@ export default function ShowContents() {
const { categoryShowInfos, partnerInfos, topShowInfo } = const { categoryShowInfos, partnerInfos, topShowInfo } =
showContentDatas || {}; showContentDatas || {};
console.log("showContentDatas", showContentDatas);
return ( return (
<> <>
{showContentDatas && {showContentDatas &&
@@ -36,6 +35,9 @@ export default function ShowContents() {
</div> </div>
</> </>
)} )}
{categoryShowInfos && categoryShowInfos.length === 0 && (
<NoResultsCategoryShows />
)}
</> </>
); );
} }

View File

@@ -4,7 +4,6 @@ import { useSelector } from "react-redux";
import { VirtualGridList } from "@enact/sandstone/VirtualList"; import { VirtualGridList } from "@enact/sandstone/VirtualList";
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator"; import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
import Spottable from "@enact/spotlight/Spottable";
import { scaleH, scaleW } from "../../../../../utils/helperMethods"; import { scaleH, scaleW } from "../../../../../utils/helperMethods";
import css from "./ShowLists.module.less"; import css from "./ShowLists.module.less";
@@ -28,7 +27,7 @@ export default function ShowLists() {
const renderItem = useCallback( const renderItem = useCallback(
({ index, ...rest }) => { ({ index, ...rest }) => {
const ItemInfo = showListDatas[index]; const itemInfo = showListDatas[index];
const { const {
catNm, catNm,
dfltThumbnailImgPath, dfltThumbnailImgPath,
@@ -41,7 +40,7 @@ export default function ShowLists() {
thumbnailUrl, thumbnailUrl,
total, total,
vtctpYn, vtctpYn,
} = ItemInfo; } = itemInfo;
return ( return (
<ShowListsItem <ShowListsItem
@@ -55,8 +54,6 @@ export default function ShowLists() {
[showListDatas] [showListDatas]
); );
console.log("showListDatas", showListDatas);
return ( return (
<Container className={css.container}> <Container className={css.container}>
{showListDatas && showListDatas.length > 0 && ( {showListDatas && showListDatas.length > 0 && (

View File

@@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import Spotlight from "@enact/spotlight"; import Spotlight from "@enact/spotlight";
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
import { getSubCategory } from "../../actions/mainActions"; import { getSubCategory } from "../../actions/mainActions";
import SectionTitle from "../../components/SectionTitle/SectionTitle"; import SectionTitle from "../../components/SectionTitle/SectionTitle";
@@ -16,6 +17,11 @@ import ItemContents from "./CategoryContents/ItemContents/ItemContents";
import ShowContents from "./CategoryContents/ShowContents/ShowContents"; import ShowContents from "./CategoryContents/ShowContents/ShowContents";
import css from "./CategoryPanel.module.less"; import css from "./CategoryPanel.module.less";
const TabContainer = SpotlightContainerDecorator(
{ enterTo: "last-focused" },
"div"
);
const getButtonTabList = () => { const getButtonTabList = () => {
return [$L("SHOW"), $L("ITEM")]; return [$L("SHOW"), $L("ITEM")];
}; };
@@ -67,12 +73,6 @@ export default function CategoryPanel() {
} }
}, [categoryDatas, tab]); }, [categoryDatas, tab]);
useEffect(() => {
const tabType = tab === 0 ? "CAT00101" : "CAT00102";
dispatch(getSubCategory({ lgCatCd, tabType }));
}, [tab, dispatch]);
const handleItemClick = useCallback( const handleItemClick = useCallback(
({ index }) => { ({ index }) => {
if (index === tab) return; if (index === tab) return;
@@ -88,16 +88,10 @@ export default function CategoryPanel() {
useEffect(() => { useEffect(() => {
const filterType = dropDownTab === 0 ? "CAT00202" : "CAT00201"; const filterType = dropDownTab === 0 ? "CAT00202" : "CAT00201";
const tabType = tab === 0 ? "CAT00101" : "CAT00102";
dispatch(getSubCategory({ lgCatCd, filterType })); dispatch(getSubCategory({ lgCatCd, tabType, filterType }));
}, [dropDownTab, dispatch]); }, [dropDownTab, dispatch, tab]);
console.log(
"panelInfos",
panelInfos.panelInfo,
"categoryDatas",
categoryDatas
);
useEffect(() => { useEffect(() => {
Spotlight.focus(`tab-${tab}`); Spotlight.focus(`tab-${tab}`);
@@ -124,7 +118,7 @@ export default function CategoryPanel() {
/> />
)} )}
{buttonTabList && buttonTabList.length > 0 && ( {buttonTabList && buttonTabList.length > 0 && (
<div className={css.tabContainer}> <TabContainer className={css.tabContainer}>
<TButtonTab <TButtonTab
contents={buttonTabList} contents={buttonTabList}
onItemClick={handleItemClick} onItemClick={handleItemClick}
@@ -139,7 +133,7 @@ export default function CategoryPanel() {
> >
{filterMethods} {filterMethods}
</TDropDown> </TDropDown>
</div> </TabContainer>
)} )}
{tab === 0 && <ShowContents />} {tab === 0 && <ShowContents />}
{tab === 1 && <ItemContents />} {tab === 1 && <ItemContents />}