fix: EIC/GB 오류해결 임시적용

This commit is contained in:
djaco
2025-07-23 15:46:13 +09:00
parent 781c541dd9
commit f4c99708a5
8 changed files with 92 additions and 62 deletions

View File

@@ -89,14 +89,14 @@ export const homeReducer = (state = initialState, action) => {
const bannerData = action.payload?.homeMainContentsBannerInfos?.[0] ?? {};
const curationTitle =
action.payload?.homeMainContentsBannerInfos?.[0].curtNm;
action.payload?.homeMainContentsBannerInfos?.[0]?.curtNm;
const curationId =
action.payload?.homeMainContentsBannerInfos?.[0].curationId;
action.payload?.homeMainContentsBannerInfos?.[0]?.curationId;
if (bannerData.bannerInfos) {
if (bannerData?.bannerInfos) {
for (let i = 0; i < bannerData.bannerInfos.length; i++) {
const info = bannerData.bannerInfos[i];
if (info.shptmDspyTpNm === "Random") {
if (info.shptmDspyTpNm === "Random" && info.bannerDetailInfos?.length > 0) {
const dataLength = info.bannerDetailInfos.length;
info.randomIndex = Math.floor(Math.random() * dataLength);
}

View File

@@ -10,7 +10,10 @@ const initialState = {
alertShowData: {},
upComingData: {
upComingChangeInfo: {},
upComingAlertShow: {},
upComingAlertShow: {
upcomAlamUseFlag: "N",
alertShows: [],
},
upComingAlertShowKeys: {},
upComingAlertShowChangeInfo: {},
},

View File

@@ -77,25 +77,25 @@ export default memo(function NoLiveCard({
} = brandChanInfoItem;
const selectedAlertShow = useMemo(() => {
if (alertShows) {
return alertShows //
.find((show) => show.showId === showId && show.strtDt === strtDt);
if (Array.isArray(alertShows)) {
return alertShows.find((show) => show?.showId === showId && show?.strtDt === strtDt) || null;
}
return {};
return null;
}, [alertShows, showId, strtDt]);
const deletedAlertShow = useMemo(() => {
if (alertShows) {
return alertShows //
.find((show) => show.showId !== showId && show.strtDt === strtDt);
if (Array.isArray(alertShows)) {
return alertShows.find((show) => show?.showId !== showId && show?.strtDt === strtDt) || null;
}
return {};
return null;
}, [alertShows, showId, strtDt]);
const isTimeConflict = alertShows //
.some((show) => show.showId !== showId && show.strtDt === strtDt);
const isTimeConflict = useMemo(() => {
if (Array.isArray(alertShows)) {
return alertShows.some((show) => show?.showId !== showId && show?.strtDt === strtDt);
}
return false;
}, [alertShows, showId, strtDt]);
const alamDispFlag = selectedAlertShow?.alamDispFlag;
const isReminderOff = upcomAlamUseFlag === "N";

View File

@@ -84,14 +84,17 @@ export default memo(function UpComingList({
strtDt,
}) =>
() => {
const selectedAlertShow = alertShows //
.find((show) => show.showId === showId && show.strtDt === strtDt);
const selectedAlertShow = Array.isArray(alertShows)
? alertShows.find((show) => show?.showId === showId && show?.strtDt === strtDt)
: null;
const deletedAlertShow = alertShows //
.find((show) => show.showId !== showId && show.strtDt === strtDt);
const deletedAlertShow = Array.isArray(alertShows)
? alertShows.find((show) => show?.showId !== showId && show?.strtDt === strtDt)
: null;
const isTimeConflict = alertShows //
.some((show) => show.showId !== showId && show.strtDt === strtDt);
const isTimeConflict = Array.isArray(alertShows)
? alertShows.some((show) => show?.showId !== showId && show?.strtDt === strtDt)
: false;
const alamDispFlag = selectedAlertShow?.alamDispFlag;
// const isShowStarted = formatGMTString(new Date()) >= strtDt;

View File

@@ -410,7 +410,7 @@ export default function HomeBanner({
spotlightId={"banner" + index}
handleShelfFocus={_handleShelfFocus}
handleItemFocus={_handleItemFocus}
randomNumber={data.randomIndex}
randomNumber={data?.randomIndex}
onFocus={handleSecondBannerFocus}
onBlur={handleSecondBannerBlur}
/>
@@ -437,7 +437,7 @@ export default function HomeBanner({
spotlightId={"banner" + index}
handleShelfFocus={_handleShelfFocus}
handleItemFocus={_handleItemFocus}
randomNumber={data.randomIndex}
randomNumber={data?.randomIndex}
/>
) : (
<SpottableComponent spotlightId={"banner" + index}>
@@ -471,14 +471,14 @@ export default function HomeBanner({
if (selectTemplate === "DSP00201" && index === 1) {
return (
<div className={!isHorizontal ? css.imgBox : undefined}>
<RandomUnitNew
<RandomUnit
bannerData={data}
isHorizontal={isHorizontal}
key={"banner" + index}
spotlightId={"banner" + index}
handleShelfFocus={_handleShelfFocus}
handleItemFocus={_handleItemFocus}
randomNumber={data.randomIndex}
randomNumber={data?.randomIndex}
/>
</div>
);

View File

@@ -61,7 +61,7 @@ export default function RandomUnit({
}) {
const dispatch = useDispatch();
const bannerDetailInfos = bannerData.bannerDetailInfos;
const bannerDetailInfos = bannerData?.bannerDetailInfos || [];
const shptmTmplCd = useSelector(
(state) => state.home?.bannerData?.shptmTmplCd,
@@ -85,7 +85,11 @@ export default function RandomUnit({
const timerRef = useRef();
const bannerDataRef = useRef(bannerData);
const randomDataRef = useRef(bannerDetailInfos[randomNumber]);
const randomDataRef = useRef(
randomNumber !== undefined && bannerDetailInfos.length > 0
? bannerDetailInfos[randomNumber]
: null
);
const topContentsLogInfo = useMemo(() => {
if (randomDataRef.current) {
@@ -174,7 +178,7 @@ export default function RandomUnit({
// 라이브 영상이 1개 라도 순간적인 네트워크 오류나, 일시적인 오류 일수 있으므로, 일정 시간을 주고, 비디오를 다시 호출 한다.
useEffect(() => {
if (bannerDetailInfos && randomNumber) {
if (bannerDetailInfos && bannerDetailInfos.length > 0 && randomNumber !== undefined) {
const indices = bannerDetailInfos
.map((info, index) => (info.shptmBanrTpNm === "LIVE" ? index : null))
.filter((index) => index !== null && index !== randomNumber);
@@ -477,10 +481,10 @@ export default function RandomUnit({
}, [sendBannerLog]);
useEffect(() => {
if (bannerData) {
if (bannerData && randomNumber !== undefined && bannerDetailInfos.length > 0) {
setRandomData(bannerDetailInfos[randomNumber]);
}
}, [bannerData, dispatch]);
}, [bannerData, randomNumber, bannerDetailInfos]);
useEffect(() => {
if (randomData && randomData.priceInfo !== null) {
@@ -525,18 +529,25 @@ export default function RandomUnit({
clearTimeout(timerRef.current);
setVideoError(true);
dispatch(finishVideoPreview());
if (liveIndicies.length > 0) {
if (liveIndicies.length > 0 && bannerDetailInfos.length > 0) {
const nextIndex = liveIndicies[0];
setLiveIndicies((prev) => prev.slice(1));
setRandomData(bannerDetailInfos[nextIndex]);
if (bannerDetailInfos[nextIndex]) {
setRandomData(bannerDetailInfos[nextIndex]);
}
setTimeout(() => {
setVideoError(false);
}, 0);
}
}
}, [broadcast]);
}, [broadcast, liveIndicies, bannerDetailInfos]);
// 데이터가 없으면 렌더링하지 않음
if (!bannerData || !randomData) {
return null;
}
return (
<>

View File

@@ -477,9 +477,11 @@ export default function MainView({ className, initService }) {
upComingAlertShow?.upcomAlamUseFlag === "Y" &&
upComingAlertShow.alertShows?.length > 0
) {
const alertList = upComingAlertShow.alertShows.filter((show) =>
isSameDateTime(show.strtDt)
);
const alertList = Array.isArray(upComingAlertShow.alertShows)
? upComingAlertShow.alertShows.filter((show) =>
show?.strtDt && isSameDateTime(show.strtDt)
)
: [];
if (alertList.length > 0) {
setAlertItems(alertList);

View File

@@ -79,9 +79,13 @@ export default function Reminders({ title, cbScrollTo }) {
useEffect(() => {
const initialSelectedItems = {};
upComingAlertShow.alertShows?.forEach((item) => {
initialSelectedItems[item.showId] = false;
});
if (upComingAlertShow?.alertShows && Array.isArray(upComingAlertShow.alertShows)) {
upComingAlertShow.alertShows.forEach((item) => {
if (item?.showId) {
initialSelectedItems[item.showId] = false;
}
});
}
setSelectedItems(initialSelectedItems);
}, [upComingAlertShow]);
@@ -161,9 +165,9 @@ export default function Reminders({ title, cbScrollTo }) {
Object.keys(selectedItems).forEach((id) => {
updatedSelectedItems[id] = false;
if (selectedItems[id]) {
if (selectedItems[id] && upComingAlertShow?.alertShows && Array.isArray(upComingAlertShow.alertShows)) {
const foundItem = upComingAlertShow.alertShows.find(
(item) => item.patnrId === id || item.showId === id
(item) => item?.patnrId === id || item?.showId === id
);
if (
@@ -175,11 +179,13 @@ export default function Reminders({ title, cbScrollTo }) {
showId: foundItem.showId,
});
}
deletedList.push({
partner: foundItem.patncNm,
contentTitle: foundItem.showNm,
contentId: foundItem.showId,
});
if (foundItem) {
deletedList.push({
partner: foundItem.patncNm,
contentTitle: foundItem.showNm,
contentId: foundItem.showId,
});
}
}
});
if (deletedList.length > 0) {
@@ -258,13 +264,17 @@ export default function Reminders({ title, cbScrollTo }) {
const handleCancelButtonClick = useCallback(() => {
setActiveDelete(false);
const initialSelectedItems = upComingAlertShow.alertShows?.reduce(
(acc, item) => {
acc[item.showId] = false;
return acc;
},
{}
);
const initialSelectedItems = upComingAlertShow?.alertShows && Array.isArray(upComingAlertShow.alertShows)
? upComingAlertShow.alertShows.reduce(
(acc, item) => {
if (item?.showId) {
acc[item.showId] = false;
}
return acc;
},
{}
)
: {};
setSelectedItems(initialSelectedItems);
setSelectAll(false);
@@ -273,9 +283,11 @@ export default function Reminders({ title, cbScrollTo }) {
const renderItem = useCallback(
({ index, ...rest }) => {
const sortedAlertShows = upComingAlertShow.alertShows
.slice()
.sort((a, b) => new Date(a.strtDt) - new Date(b.strtDt));
const sortedAlertShows = upComingAlertShow?.alertShows && Array.isArray(upComingAlertShow.alertShows)
? upComingAlertShow.alertShows
.slice()
.sort((a, b) => new Date(a.strtDt) - new Date(b.strtDt))
: [];
const listItem = sortedAlertShows[index];
@@ -302,7 +314,7 @@ export default function Reminders({ title, cbScrollTo }) {
selected={selectedItems[listItem.showId]}
onToggle={handleItemToggle(listItem.showId)}
index={index}
length={upComingAlertShow.alertShows.length}
length={upComingAlertShow?.alertShows?.length || 0}
/>
);
},
@@ -346,7 +358,7 @@ export default function Reminders({ title, cbScrollTo }) {
</>
)}
{upComingAlertShow.alertShows &&
{upComingAlertShow?.alertShows &&
upComingAlertShow.alertShows.length > 0 ? (
<TButton
type={TYPES.mypage}
@@ -363,8 +375,7 @@ export default function Reminders({ title, cbScrollTo }) {
<TBody cbScrollTo={cbScrollTo} className={css.tBody}>
<div className={css.remindersContentsWrap}>
{upComingAlertShow &&
upComingAlertShow.alertShows &&
{upComingAlertShow?.alertShows &&
upComingAlertShow.alertShows.length > 0 ? (
<TVirtualGridList
spotlightId={SpotlightIds.MY_PAGE_REMINDRES_BOX}