[search] IF-LGSP-097 검색 메인 조회 적용
- searchpanel진입시 화면에 적용. - your recent searches부분은 미적용. - hotpicksforyou링크연결.
This commit is contained in:
@@ -8,6 +8,12 @@ const initialState = {
|
||||
searchTimestamp: null,
|
||||
shopperHouseData: null,
|
||||
shopperHouseSearchId: null,
|
||||
// 🔽 검색 메인 데이터 추가
|
||||
searchMainData: {
|
||||
topSearchs: [],
|
||||
popularBrands: [],
|
||||
hotPicksForYou: [],
|
||||
},
|
||||
};
|
||||
|
||||
export const searchReducer = (state = initialState, action) => {
|
||||
@@ -77,7 +83,7 @@ export const searchReducer = (state = initialState, action) => {
|
||||
const resultData = action.payload?.data?.result;
|
||||
|
||||
if (!resultData) {
|
||||
console.error('[searchReducer] Invalid shopperHouse data structure');
|
||||
console.error("[searchReducer] Invalid shopperHouse data structure");
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -87,8 +93,8 @@ export const searchReducer = (state = initialState, action) => {
|
||||
const searchId = results.length > 0 ? results[0].searchId : null;
|
||||
|
||||
// [VoiceInput] Redux에 searchId 저장 로그
|
||||
console.log('[VoiceInput] 💾 Redux에 searchId 저장');
|
||||
console.log('[VoiceInput] └─ searchId:', searchId || '(없음)');
|
||||
console.log("[VoiceInput] 💾 Redux에 searchId 저장");
|
||||
console.log("[VoiceInput] └─ searchId:", searchId || "(없음)");
|
||||
|
||||
return {
|
||||
...state,
|
||||
@@ -103,13 +109,68 @@ export const searchReducer = (state = initialState, action) => {
|
||||
}
|
||||
|
||||
case types.CLEAR_SHOPPERHOUSE_DATA:
|
||||
console.log('[VoiceInput] 🧹 Redux shopperHouseData 초기화 (searchId 리셋)');
|
||||
console.log(
|
||||
"[VoiceInput] 🧹 Redux shopperHouseData 초기화 (searchId 리셋)"
|
||||
);
|
||||
return {
|
||||
...state,
|
||||
shopperHouseData: null,
|
||||
shopperHouseSearchId: null,
|
||||
};
|
||||
|
||||
// 🔽 검색 메인 데이터 처리
|
||||
case types.GET_SEARCH_MAIN: {
|
||||
console.log(
|
||||
"🔍 [searchReducer] GET_SEARCH_MAIN 받은 payload:",
|
||||
action.payload
|
||||
);
|
||||
|
||||
// 여러 가능한 구조 확인
|
||||
let resultData = null;
|
||||
|
||||
if (action.payload?.result) {
|
||||
// payload.result 구조
|
||||
resultData = action.payload.result;
|
||||
console.log("✅ [searchReducer] payload.result 구조 확인");
|
||||
} else if (action.payload?.data?.result) {
|
||||
// payload.data.result 구조
|
||||
resultData = action.payload.data.result;
|
||||
console.log("✅ [searchReducer] payload.data.result 구조 확인");
|
||||
} else if (action.payload?.data) {
|
||||
// payload.data에 직접 데이터가 있는 경우
|
||||
resultData = action.payload.data;
|
||||
console.log("✅ [searchReducer] payload.data 직접 구조 확인");
|
||||
}
|
||||
|
||||
if (!resultData) {
|
||||
console.error("[searchReducer] ❌ Invalid searchMain data structure");
|
||||
console.error("받은 payload:", JSON.stringify(action.payload, null, 2));
|
||||
return state;
|
||||
}
|
||||
|
||||
console.log("[searchReducer] ✅ GET_SEARCH_MAIN success");
|
||||
|
||||
return {
|
||||
...state,
|
||||
searchMainData: {
|
||||
topSearchs: resultData.topSearchs || [],
|
||||
popularBrands: resultData.popularBrands || [],
|
||||
hotPicksForYou: resultData.hotPicksForYou || [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case types.CLEAR_SEARCH_MAIN_DATA:
|
||||
console.log("[searchReducer] 🧹 searchMainData 초기화");
|
||||
return {
|
||||
...state,
|
||||
searchMainData: {
|
||||
topSearchs: [],
|
||||
popularBrands: [],
|
||||
hotPicksForYou: [],
|
||||
},
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user