[Home] httpHeader 조건문 추가

Detail Notes :
 
1. TV에서 Home이 정상적으로 출력이 안됨
> 너무 빨리 dispatch를 날려서 header 정보가 있을 경우에만 dispatch 하도록 처리
This commit is contained in:
jangheon Pyo
2024-04-01 16:21:06 +09:00
parent e1787abd73
commit ca1f8fd620

View File

@@ -55,40 +55,42 @@ const hasTemplateCodeWithValue = (array, value) =>
export default function HomePanel({ isOnTop }) {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getHomeLayout());
dispatch(getHomeMainContents());
dispatch(getBestSeller());
dispatch(
getSubCategory({
lgCatCd: "1017", //LG Electronics Base
pageSize: 10,
tabType: "CAT00102",
filterType: "CAT00201",
})
); //
dispatch(getTop20Show());
}, [dispatch]);
const { getScrollTo, scrollTop } = useScrollTo();
useDebugKey({ isLandingPage: true });
useEffect(() => {
dispatch(
getOnSaleInfo({
categoryIncFlag: "Y",
lgCatCd: "",
saleInfosIncFlag: "N",
homeSaleInfosIncFlag: "Y",
})
);
}, [dispatch]);
const homeLayoutInfo = useSelector((state) => state.home.layoutData);
const homeTopDisplayInfos = useSelector(
(state) => state.home.mainContentsData.homeTopDisplayInfos
);
const { httpHeader } = useSelector((state) => state.common);
const popupVisible = useSelector((state) => state.common.popup.popupVisible);
const isGnbOpened = useSelector((state) => state.common.isGnbOpened);
useEffect(() => {
if (httpHeader) {
dispatch(getHomeLayout());
dispatch(getHomeMainContents());
dispatch(getBestSeller());
dispatch(
getSubCategory({
lgCatCd: "1017", //LG Electronics Base
pageSize: 10,
tabType: "CAT00102",
filterType: "CAT00201",
})
);
dispatch(getTop20Show());
dispatch(
getOnSaleInfo({
categoryIncFlag: "Y",
lgCatCd: "",
saleInfosIncFlag: "N",
homeSaleInfosIncFlag: "Y",
})
);
}
}, [dispatch, httpHeader]);
const { getScrollTo, scrollTop } = useScrollTo();
useDebugKey({ isLandingPage: true });
const [selectTemplate, setSelectTemplate] = useState(null);
const [homeLayoutInfoDetail, setHomeLayoutInfoDetail] = useState([]);
useEffect(() => {
@@ -146,74 +148,76 @@ export default function HomePanel({ isOnTop }) {
<TPanel className={css.panel} onCancel={onCancel}>
<TBody className={css.tBody} cbScrollTo={getScrollTo}>
{homeLayoutInfo && (
<div className={css.orderableFlexContainer}>
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.TOP
) &&
selectTemplate && (
<HomeBanner
selectTemplate={selectTemplate}
scrollTop={scrollTop}
<>
<div className={css.orderableFlexContainer}>
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.TOP
) &&
selectTemplate && (
<HomeBanner
selectTemplate={selectTemplate}
scrollTop={scrollTop}
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.TOP
)}
className={css.homeBannerWrap}
/>
)}
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.CATEGORY_ITEM
) && (
<SubCategory
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.TOP
TEMPLATE_CODE_CONF.CATEGORY_ITEM
)}
className={css.homeBannerWrap}
/>
)}
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.CATEGORY_ITEM
) && (
<SubCategory
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.CATEGORY_ITEM
)}
/>
)}
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.ON_SALE
) && (
<HomeOnSale
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.ON_SALE
)}
/>
)}
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.POPULAR_SHOW
) && (
<PopularShow
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.POPULAR_SHOW
)}
/>
)}
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.BEST_SELLER
) && (
<BestSeller
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.BEST_SELLER
)}
/>
)}
</div>
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.ON_SALE
) && (
<HomeOnSale
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.ON_SALE
)}
/>
)}
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.POPULAR_SHOW
) && (
<PopularShow
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.POPULAR_SHOW
)}
/>
)}
{hasTemplateCodeWithValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.BEST_SELLER
) && (
<BestSeller
order={getOrderByValue(
homeLayoutInfoDetail,
TEMPLATE_CODE_CONF.BEST_SELLER
)}
/>
)}
</div>
<TButton
className={css.tButton}
onClick={handleTopButtonClick}
size={null}
type={TYPES.topButton}
/>
</>
)}
<TButton
className={css.tButton}
onClick={handleTopButtonClick}
size={null}
type={TYPES.topButton}
/>
</TBody>
<TPopUp
kind="exitPopup"