[FeaturedBrandsPanel] edited, variables
This commit is contained in:
@@ -34,7 +34,7 @@ import TPopUp from "../../components/TPopUp/TPopUp";
|
|||||||
import TVerticalPagenator from "../../components/TVerticalPagenator/TVerticalPagenator";
|
import TVerticalPagenator from "../../components/TVerticalPagenator/TVerticalPagenator";
|
||||||
import useLogService from "../../hooks/useLogService";
|
import useLogService from "../../hooks/useLogService";
|
||||||
import usePrevious from "../../hooks/usePrevious";
|
import usePrevious from "../../hooks/usePrevious";
|
||||||
import { ACTIVE_POPUP, panel_names } from "../../utils/Config";
|
import { ACTIVE_POPUP, LOG_MENU, panel_names } from "../../utils/Config";
|
||||||
import { $L } from "../../utils/helperMethods";
|
import { $L } from "../../utils/helperMethods";
|
||||||
import Banner from "./Banner/Banner";
|
import Banner from "./Banner/Banner";
|
||||||
import FeaturedBestSeller from "./FeaturedBestSeller/FeaturedBestSeller";
|
import FeaturedBestSeller from "./FeaturedBestSeller/FeaturedBestSeller";
|
||||||
@@ -261,14 +261,14 @@ export default function FeaturedBrandsPanel({
|
|||||||
const cbChangePageRef = useRef(null);
|
const cbChangePageRef = useRef(null);
|
||||||
const orderableFlexContainerRef = useRef(null);
|
const orderableFlexContainerRef = useRef(null);
|
||||||
|
|
||||||
const previousPanelIsDetail = Object.keys(panelInfo).length >= 6;
|
const fromDeepLink = Object.entries(panelInfo) //
|
||||||
const previousActionOccurredInGNB =
|
.some(([key, value]) => key === "linkTpCd" && value);
|
||||||
|
const fromDetail = Object.keys(panelInfo).length >= 6;
|
||||||
|
const fromGNB =
|
||||||
Object.keys(panelInfo).length === 1 &&
|
Object.keys(panelInfo).length === 1 &&
|
||||||
Object.prototype.hasOwnProperty.call(panelInfo, "patnrId");
|
Object.prototype.hasOwnProperty.call(panelInfo, "patnrId");
|
||||||
const previousActionOccurredInQuickMenu =
|
const fromQuickMenu =
|
||||||
panelInfo?.from && panelInfo.from === "quickMenu";
|
panelInfo?.from && panelInfo.from === LOG_MENU.FEATURED_BRANDS_QUICK_MENU;
|
||||||
const isCameThroughDeepLink = Object.entries(panelInfo) //
|
|
||||||
.some(([key, value]) => key === "linkTpCd" && value);
|
|
||||||
|
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// console.log(
|
// console.log(
|
||||||
@@ -286,12 +286,7 @@ export default function FeaturedBrandsPanel({
|
|||||||
}, [dispatch, panelInfo?.noResetFlag]);
|
}, [dispatch, panelInfo?.noResetFlag]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (panelInfo?.patnrId && (fromGNB || fromQuickMenu || fromDeepLink)) {
|
||||||
panelInfo?.patnrId &&
|
|
||||||
(previousActionOccurredInGNB ||
|
|
||||||
previousActionOccurredInQuickMenu ||
|
|
||||||
isCameThroughDeepLink)
|
|
||||||
) {
|
|
||||||
// console.log(
|
// console.log(
|
||||||
// "%c pyh initial rendered effect",
|
// "%c pyh initial rendered effect",
|
||||||
// "background: dodgerblue; color: white"
|
// "background: dodgerblue; color: white"
|
||||||
@@ -304,12 +299,7 @@ export default function FeaturedBrandsPanel({
|
|||||||
cbChangePageRef.current(0, false);
|
cbChangePageRef.current(0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [fromDeepLink, fromGNB, fromQuickMenu, panelInfo?.patnrId]);
|
||||||
panelInfo?.patnrId,
|
|
||||||
previousActionOccurredInGNB,
|
|
||||||
previousActionOccurredInQuickMenu,
|
|
||||||
isCameThroughDeepLink,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!brandInfo) {
|
if (!brandInfo) {
|
||||||
@@ -320,11 +310,7 @@ export default function FeaturedBrandsPanel({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (brandInfo && isInitialRendered && panelInfo) {
|
if (brandInfo && isInitialRendered && panelInfo) {
|
||||||
if (
|
if (fromGNB || fromQuickMenu || fromDeepLink) {
|
||||||
previousActionOccurredInGNB ||
|
|
||||||
previousActionOccurredInQuickMenu ||
|
|
||||||
isCameThroughDeepLink
|
|
||||||
) {
|
|
||||||
// console.log(
|
// console.log(
|
||||||
// "%c pyh second rendered(gnb, quick, link) effect",
|
// "%c pyh second rendered(gnb, quick, link) effect",
|
||||||
// "background: dodgerblue; color: white"
|
// "background: dodgerblue; color: white"
|
||||||
@@ -338,7 +324,7 @@ export default function FeaturedBrandsPanel({
|
|||||||
setIsInitialRendered(false);
|
setIsInitialRendered(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousPanelIsDetail) {
|
if (fromDetail) {
|
||||||
// console.log(
|
// console.log(
|
||||||
// "%c pyh second rendered(detail) effect",
|
// "%c pyh second rendered(detail) effect",
|
||||||
// "background: dodgerblue; color: white"
|
// "background: dodgerblue; color: white"
|
||||||
@@ -353,12 +339,12 @@ export default function FeaturedBrandsPanel({
|
|||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
brandInfo,
|
brandInfo,
|
||||||
|
fromDeepLink,
|
||||||
|
fromDetail,
|
||||||
|
fromGNB,
|
||||||
|
fromQuickMenu,
|
||||||
isInitialRendered,
|
isInitialRendered,
|
||||||
panelInfo,
|
panelInfo,
|
||||||
previousActionOccurredInGNB,
|
|
||||||
previousActionOccurredInQuickMenu,
|
|
||||||
previousPanelIsDetail,
|
|
||||||
isCameThroughDeepLink,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -401,7 +387,7 @@ export default function FeaturedBrandsPanel({
|
|||||||
|
|
||||||
let targetId = "spotlightId-" + panelInfo?.patnrId;
|
let targetId = "spotlightId-" + panelInfo?.patnrId;
|
||||||
|
|
||||||
if (previousPanelIsDetail) {
|
if (fromDetail) {
|
||||||
// console.log(
|
// console.log(
|
||||||
// "%c pyh focus(detail) effect",
|
// "%c pyh focus(detail) effect",
|
||||||
// "background: dodgerblue; color: white"
|
// "background: dodgerblue; color: white"
|
||||||
@@ -460,10 +446,10 @@ export default function FeaturedBrandsPanel({
|
|||||||
}, [
|
}, [
|
||||||
dispatch,
|
dispatch,
|
||||||
firstFocusableTargetId,
|
firstFocusableTargetId,
|
||||||
|
fromDetail,
|
||||||
isInitialFocusOccurred,
|
isInitialFocusOccurred,
|
||||||
isOnTop,
|
isOnTop,
|
||||||
panelInfo,
|
panelInfo,
|
||||||
previousPanelIsDetail,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -658,6 +644,8 @@ export default function FeaturedBrandsPanel({
|
|||||||
{shouldRenderComponent(brandInfo) && selectedBrandInfo && (
|
{shouldRenderComponent(brandInfo) && selectedBrandInfo && (
|
||||||
<QuickMenu
|
<QuickMenu
|
||||||
brandInfo={brandInfo}
|
brandInfo={brandInfo}
|
||||||
|
fromGNB={fromGNB}
|
||||||
|
fromQuickMenu={fromQuickMenu}
|
||||||
handleItemFocus={handleItemFocus}
|
handleItemFocus={handleItemFocus}
|
||||||
panelInfo={panelInfo}
|
panelInfo={panelInfo}
|
||||||
selectedPatnrId={selectedPatnrId}
|
selectedPatnrId={selectedPatnrId}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ const Container = SpotlightContainerDecorator(
|
|||||||
|
|
||||||
export default memo(function QuickMenu({
|
export default memo(function QuickMenu({
|
||||||
brandInfo,
|
brandInfo,
|
||||||
|
fromGNB,
|
||||||
|
fromQuickMenu,
|
||||||
handleItemFocus,
|
handleItemFocus,
|
||||||
panelInfo,
|
panelInfo,
|
||||||
selectedPatnrId,
|
selectedPatnrId,
|
||||||
@@ -27,17 +29,8 @@ export default memo(function QuickMenu({
|
|||||||
|
|
||||||
const ulRef = useRef(null);
|
const ulRef = useRef(null);
|
||||||
|
|
||||||
const previousActionOccurredInGNB =
|
|
||||||
Object.keys(panelInfo).length === 1 &&
|
|
||||||
Object.prototype.hasOwnProperty.call(panelInfo, "patnrId");
|
|
||||||
|
|
||||||
const previousActionOccurredInQuickMenu =
|
|
||||||
panelInfo?.from && panelInfo.from === "quickMenu";
|
|
||||||
// const actionOccurredInQuickMenu =
|
|
||||||
// panelInfo?.from && panelInfo?.from === "quickMenu";
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (previousActionOccurredInGNB && !previousActionOccurredInQuickMenu) {
|
if (fromGNB && !fromQuickMenu) {
|
||||||
const container = ulRef.current;
|
const container = ulRef.current;
|
||||||
const item = document.querySelector(
|
const item = document.querySelector(
|
||||||
`[data-spotlight-id="spotlightId-${panelInfo?.patnrId}"]`
|
`[data-spotlight-id="spotlightId-${panelInfo?.patnrId}"]`
|
||||||
@@ -68,16 +61,10 @@ export default memo(function QuickMenu({
|
|||||||
x = scaleW(offsetFromContainerLeft - containerWidth + clippedWidht);
|
x = scaleW(offsetFromContainerLeft - containerWidth + clippedWidht);
|
||||||
}
|
}
|
||||||
|
|
||||||
// quickMenuItem action과 gnb action을 나눠야 한다..
|
|
||||||
scrollLeft({ x });
|
scrollLeft({ x });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [fromGNB, fromQuickMenu, panelInfo?.patnrId, scrollLeft]);
|
||||||
panelInfo?.patnrId,
|
|
||||||
previousActionOccurredInGNB,
|
|
||||||
previousActionOccurredInQuickMenu,
|
|
||||||
scrollLeft,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const _handleItemFocus = useCallback(() => {
|
const _handleItemFocus = useCallback(() => {
|
||||||
if (handleItemFocus) {
|
if (handleItemFocus) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import IcPartnersDefault from "../../../../../assets/images/ic-tab-partners-defa
|
|||||||
import { resetPanels, updatePanel } from "../../../../actions/panelActions";
|
import { resetPanels, updatePanel } from "../../../../actions/panelActions";
|
||||||
import CustomImage from "../../../../components/CustomImage/CustomImage";
|
import CustomImage from "../../../../components/CustomImage/CustomImage";
|
||||||
import useScrollReset from "../../../../hooks/useScrollReset";
|
import useScrollReset from "../../../../hooks/useScrollReset";
|
||||||
import { panel_names } from "../../../../utils/Config";
|
import { LOG_MENU, panel_names } from "../../../../utils/Config";
|
||||||
import { $L } from "../../../../utils/helperMethods";
|
import { $L } from "../../../../utils/helperMethods";
|
||||||
import css from "./QuickMenuItem.module.less";
|
import css from "./QuickMenuItem.module.less";
|
||||||
|
|
||||||
@@ -54,10 +54,11 @@ export default memo(function QuickMenuItem({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const from = LOG_MENU.FEATURED_BRANDS_QUICK_MENU;
|
||||||
const name = panel_names.FEATURED_BRANDS_PANEL;
|
const name = panel_names.FEATURED_BRANDS_PANEL;
|
||||||
|
|
||||||
dispatch(resetPanels([{ name }]));
|
dispatch(resetPanels([{ name }]));
|
||||||
dispatch(updatePanel({ name, panelInfo: { patnrId, from: "quickMenu" } }));
|
dispatch(updatePanel({ name, panelInfo: { from, patnrId } }));
|
||||||
setIsInitialRendered(true);
|
setIsInitialRendered(true);
|
||||||
resetStates();
|
resetStates();
|
||||||
}, [dispatch, patnrId, resetStates, selectedPatnrId, setIsInitialRendered]);
|
}, [dispatch, patnrId, resetStates, selectedPatnrId, setIsInitialRendered]);
|
||||||
|
|||||||
Reference in New Issue
Block a user