🕐 커밋 시간: 2025. 12. 10. 18:29:18 📊 변경 통계: • 총 파일: 5개 • 추가: +133줄 📝 수정된 파일: ~ com.twin.app.shoptime/src/actions/actionTypes.js ~ com.twin.app.shoptime/src/actions/brandActions.js ~ com.twin.app.shoptime/src/reducers/brandReducer.js ~ com.twin.app.shoptime/src/views/DetailPanel/ProductAllSection/ProductAllSection.jsx ~ com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx 🔧 주요 변경 내용: • 타입 시스템 안정성 강화 • 핵심 비즈니스 로직 개선 • 중간 규모 기능 개선
266 lines
6.0 KiB
JavaScript
266 lines
6.0 KiB
JavaScript
import { types } from "../actions/actionTypes";
|
|
|
|
const initialState = {
|
|
brandInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandLayoutInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandLiveChannelInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandTsvInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandRecommendedShowInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandCreatorsInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandSeriesInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandCategoryInfoData: {
|
|
data: {},
|
|
},
|
|
|
|
brandBestSellerData: {
|
|
data: {},
|
|
},
|
|
|
|
brandShowroomData: {
|
|
data: {},
|
|
},
|
|
|
|
brandRecentlyAiredData: {
|
|
data: {},
|
|
},
|
|
|
|
brandShopByShowData: {
|
|
data: {},
|
|
},
|
|
|
|
brandTopBannerData: {
|
|
data: {},
|
|
},
|
|
|
|
// 🆕 [251210] patnrId=21 카테고리 그룹 데이터 저장소
|
|
brandShopByShowCategoryGroups: {},
|
|
};
|
|
|
|
export const brandReducer = (state = initialState, action) => {
|
|
switch (action.type) {
|
|
case types.GET_BRAND_LIST:
|
|
return {
|
|
...state,
|
|
brandInfoData: action.payload,
|
|
};
|
|
|
|
case types.GET_BRAND_LAYOUT_INFO:
|
|
return {
|
|
...state,
|
|
brandLayoutInfoData: action.payload,
|
|
};
|
|
|
|
case types.GET_BRAND_LIVE_CHANNEL_INFO:
|
|
return {
|
|
...state,
|
|
brandLiveChannelInfoData: action.payload,
|
|
};
|
|
|
|
case types.GET_BRAND_CHAN_INFO: {
|
|
const brandChanInfo =
|
|
action.payload && action.payload.data?.brandChanInfo;
|
|
return {
|
|
...state,
|
|
brandLiveChannelInfoData: {
|
|
...state.brandLiveChannelInfoData,
|
|
data: {
|
|
...state.brandLiveChannelInfoData.data,
|
|
brandChanInfo,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
case types.GET_BRAND_TSV_INFO:
|
|
return {
|
|
...state,
|
|
brandTsvInfoData: action.payload,
|
|
};
|
|
|
|
case types.GET_BRAND_RECOMMENDED_SHOW_INFO: {
|
|
return {
|
|
...state,
|
|
brandRecommendedShowInfoData: action.payload,
|
|
};
|
|
}
|
|
|
|
case types.GET_BRAND_CREATORS_INFO: {
|
|
const barndCreatorsShowInfo =
|
|
action.payload &&
|
|
action.payload.data.barndCreatorsShowInfo?.slice(0, 10);
|
|
const data = { ...action.payload.data, barndCreatorsShowInfo };
|
|
return {
|
|
...state,
|
|
brandCreatorsInfoData: {
|
|
...action.payload,
|
|
data,
|
|
},
|
|
};
|
|
}
|
|
|
|
case types.GET_BRAND_SERIES_INFO: {
|
|
return {
|
|
...state,
|
|
brandSeriesInfoData: action.payload,
|
|
};
|
|
}
|
|
|
|
case types.GET_BRAND_CATEGORY_INFO: {
|
|
return {
|
|
...state,
|
|
brandCategoryInfoData: action.payload,
|
|
};
|
|
}
|
|
|
|
case types.GET_BRAND_CATEGORY_PRODUCT_INFO: {
|
|
const brandCategoryProductInfo =
|
|
action.payload && action.payload.data.brandCategoryProductInfo;
|
|
return {
|
|
...state,
|
|
brandCategoryInfoData: {
|
|
...state.brandCategoryInfoData,
|
|
data: {
|
|
...state.brandCategoryInfoData.data,
|
|
brandCategoryProductInfo,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
case types.GET_BRAND_BEST_SELLER:
|
|
return {
|
|
...state,
|
|
brandBestSellerData: action.payload,
|
|
};
|
|
|
|
case types.GET_BRAND_SHOWROOM:
|
|
return {
|
|
...state,
|
|
brandShowroomData: action.payload,
|
|
};
|
|
|
|
case types.GET_BRAND_RECENTLY_AIRED:
|
|
return {
|
|
...state,
|
|
brandRecentlyAiredData: action.payload,
|
|
};
|
|
|
|
case types.GET_BRAND_SHOP_BY_SHOW: {
|
|
// 일부 응답은 리스트 없이 내려와 기존 데이터를 덮어 지우는 문제가 있어 조건부 병합
|
|
const prevData = state.brandShopByShowData?.data || {};
|
|
const nextData = action.payload?.data || {};
|
|
const hasNextList = Array.isArray(nextData.brandShopByShowContsList);
|
|
|
|
// 리스트가 없으면 이전 리스트 유지
|
|
const mergedData = hasNextList
|
|
? nextData
|
|
: { ...prevData, ...nextData, brandShopByShowContsList: prevData.brandShopByShowContsList };
|
|
|
|
// 🆕 [251210] patnrId=21인 경우 그룹 데이터 별도 저장
|
|
const updatedCategoryGroups = { ...state.brandShopByShowCategoryGroups };
|
|
|
|
if (action.payload?.patnrId === 21 || action.payload?.patnrId === "21") {
|
|
const patnrId = String(action.payload.patnrId);
|
|
|
|
// patnrId별 그룹 데이터가 없으면 초기화
|
|
if (!updatedCategoryGroups[patnrId]) {
|
|
updatedCategoryGroups[patnrId] = {};
|
|
}
|
|
|
|
// 현재 contsId에 대한 그룹 정보 저장
|
|
if (nextData.brandShopByShowContsInfo?.contsId) {
|
|
const contsId = nextData.brandShopByShowContsInfo.contsId;
|
|
updatedCategoryGroups[patnrId][contsId] = nextData.brandShopByShowContsInfo;
|
|
}
|
|
}
|
|
|
|
return {
|
|
...state,
|
|
brandShopByShowData: {
|
|
...action.payload,
|
|
data: mergedData,
|
|
},
|
|
brandShopByShowCategoryGroups: updatedCategoryGroups,
|
|
};
|
|
}
|
|
|
|
case types.GET_BRAND_TOP_BANNER:
|
|
return {
|
|
...state,
|
|
brandTopBannerData: action.payload,
|
|
};
|
|
|
|
case types.SET_BRAND_LIVE_CHANNEL_UPCOMING:
|
|
return {
|
|
...state,
|
|
brandLiveChannelInfoData: action.payload,
|
|
};
|
|
|
|
case types.SET_BRAND_CHAN_INFO:
|
|
return {
|
|
...state,
|
|
brandLiveChannelInfoData: action.payload,
|
|
};
|
|
|
|
case types.RESET_BRAND_STATE_EXCEPT_BRAND_INFO: {
|
|
const { brandInfoData, ...otherInitialState } = initialState;
|
|
return {
|
|
...state,
|
|
...otherInitialState,
|
|
};
|
|
}
|
|
|
|
case types.RESET_BRAND_LAYOUT_INFO: {
|
|
return {
|
|
...state,
|
|
brandLayoutInfoData: {
|
|
data: {},
|
|
},
|
|
};
|
|
}
|
|
|
|
// 🆕 [251210] patnrId=21 카테고리 그룹 데이터 설정
|
|
case types.SET_BRAND_SHOP_BY_SHOW_CATEGORY_GROUPS: {
|
|
return {
|
|
...state,
|
|
brandShopByShowCategoryGroups: {
|
|
...state.brandShopByShowCategoryGroups,
|
|
...action.payload,
|
|
},
|
|
};
|
|
}
|
|
|
|
// 🆕 [251210] patnrId=21 카테고리 그룹 데이터 초기화
|
|
case types.RESET_BRAND_SHOP_BY_SHOW_CATEGORY_GROUPS: {
|
|
return {
|
|
...state,
|
|
brandShopByShowCategoryGroups: {},
|
|
};
|
|
}
|
|
|
|
default:
|
|
return state;
|
|
}
|
|
};
|