[mainSlice] 홈화면 popular show 연결을 위한 api

This commit is contained in:
junghoon86.park
2024-01-29 13:41:24 +09:00
parent 47b465d182
commit e39e8230d0
3 changed files with 41 additions and 3 deletions

View File

@@ -6,10 +6,14 @@ import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
import { getBrandList } from "../features/brand/brandsSlice"; import { getBrandList } from "../features/brand/brandsSlice";
import { getAuthenticationCode } from "../features/device/deviceSlice"; import { getAuthenticationCode } from "../features/device/deviceSlice";
import { getHomeMenu, getHomeLayout, getHomeMainContents } from "../features/home/homeSlice"; import {
getHomeMenu,
getHomeLayout,
getHomeMainContents,
} from "../features/home/homeSlice";
import { getMyRecommandedKeyword } from "../features/mypage/myPageSlice"; import { getMyRecommandedKeyword } from "../features/mypage/myPageSlice";
import { getOnSaleInfo } from "../features/onSale/onSaleSlice"; import { getOnSaleInfo } from "../features/onSale/onSaleSlice";
import { getSubCategory } from "../features/main/mainSlice"; import { getSubCategory, getTop20Show } from "../features/main/mainSlice";
import { getBestSeller } from "../features/product/productSlice"; import { getBestSeller } from "../features/product/productSlice";
import MainView from "../views/MainView/MainView"; import MainView from "../views/MainView/MainView";
import css from "./App.module.less"; import css from "./App.module.less";
@@ -35,6 +39,7 @@ function AppBase(props) {
filterType: "", filterType: "",
}) })
); );
dispatch(getTop20Show());
}, [dispatch]); }, [dispatch]);
return <MainView />; return <MainView />;

View File

@@ -41,6 +41,7 @@ export const URLS = {
//main controller //main controller
GET_SUB_CATEGORY: "/lgsp/v1/main/subcategory.lge", GET_SUB_CATEGORY: "/lgsp/v1/main/subcategory.lge",
GET_TOP20_SHOW: "/lgsp/v1/main/top/show.lge",
}; };
export const getUrl = (endStr) => { export const getUrl = (endStr) => {

View File

@@ -35,6 +35,35 @@ export const getSubCategory = createAsyncThunk(
} }
); );
//메인화면 Live Show 정보 조회
export const getTop20Show = createAsyncThunk(
"main/getTop20Show",
async (_, thunkAPI) => {
const onSuccess = (response) => {
console.log("getTop20Show onSuccess ", response.data);
thunkAPI.dispatch(
mainSlice.actions.updateSubCategoryData(response.data.data)
);
};
const onFail = (error) => {
console.log("getTop20Show onFail", error);
};
TAxios(
thunkAPI.dispatch,
thunkAPI.getState,
"get",
URLS.GET_TOP20_SHOW,
{},
{},
onSuccess,
onFail
);
}
);
const initialState = { const initialState = {
subCategoryData: {}, subCategoryData: {},
}; };
@@ -46,9 +75,12 @@ export const mainSlice = createSlice({
updateSubCategoryData: (state, action) => { updateSubCategoryData: (state, action) => {
state.subCategoryData = action.payload; state.subCategoryData = action.payload;
}, },
updateTop20Show: (state, action) => {
state.top20ShowData = action.payload;
},
}, },
}); });
export const { updateSubCategoryData } = mainSlice.actions; export const { updateSubCategoryData, updateTop20Show } = mainSlice.actions;
export default mainSlice.reducer; export default mainSlice.reducer;