[FeaturedBrandsPanel] API 구조 변경에 따른 업데이트
Detail Notes : 1. features/brand/featuredBrnadsSlice.js 생성 및 logic 추가 (store 추가완료) 2. api/apiConfig.js brand-controller URLS 추가 P.S : api/featuredBrandsApi.js 파일은 해당 영역의 panel에서 구조 변경 후 삭제하겠습니다.
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import css from "./App.module.less";
|
||||
import MainView from "../views/MainView/MainView";
|
||||
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
|
||||
|
||||
import { getBrandList } from "../features/brand/featuredBrandsSlice";
|
||||
import { getAuthenticationCode } from "../features/device/deviceSlice";
|
||||
import { getHomeMenu } from "../features/home/homeSlice";
|
||||
import { getOnSaleInfo } from "../features/onSale/onSaleSlice";
|
||||
import MainView from "../views/MainView/MainView";
|
||||
import css from "./App.module.less";
|
||||
|
||||
function AppBase(props) {
|
||||
const dispatch = useDispatch();
|
||||
@@ -16,6 +18,7 @@ function AppBase(props) {
|
||||
dispatch(getAuthenticationCode());
|
||||
dispatch(getHomeMenu());
|
||||
dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" }));
|
||||
dispatch(getBrandList());
|
||||
}, [dispatch]);
|
||||
|
||||
return <MainView />;
|
||||
|
||||
@@ -19,6 +19,11 @@ export const URLS = {
|
||||
GET_BRAND_LAYOUT_INFO: "/lgsp/v1/brand/shelf.lge",
|
||||
GET_BRAND_LIVE_CHANNEL_INFO: "/lgsp/v1/brand/live.lge",
|
||||
GET_BRAND_TODAYS_DEALS: "/lgsp/v1/brand/tsv.lge",
|
||||
GET_BRAND_RECOMMENDED_SHOW_INFO: "/lgsp/v1/brand/recommend.lge",
|
||||
GET_BRAND_CREATORS_INFO: "/lgsp/v1/brand/creators.lge",
|
||||
GET_BRAND_SERIES_INFO: "/lgsp/v1/brand/series.lge",
|
||||
GET_BRAND_CATEGORY_INFO: "/lgsp/v1/brand/category.lge",
|
||||
GET_BRAND_BEST_SELLET: "/lgsp/v1/brand/best.lge",
|
||||
|
||||
//on-sale controller
|
||||
GET_ON_SALE_INFO: "/lgsp/v1/onsale/onsale.lge",
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
import { URLS } from "../../api/apiConfig";
|
||||
import { TAxios } from "../../api/TAxios";
|
||||
|
||||
// Featured Brands 정보 조회 IF-LGSP-304
|
||||
// @@pyh Todo, 기존의 key가 brandList에서 brandInfo로 변경 됨에 따라 함수명 또한 바뀔 수 있음 (문서 확인 후 변경 처리)
|
||||
export const getBrandList = createAsyncThunk(
|
||||
"featuredBrands/getBrandList",
|
||||
|
||||
async (_, thunkAPI) => {
|
||||
const onSuccess = (response) => {
|
||||
console.log("getBrandList onSuccess ", response.data);
|
||||
|
||||
thunkAPI.dispatch(featuredBrandsSlice.actions.updateBrandInfo(response.data.data));
|
||||
};
|
||||
|
||||
const onFail = (error) => {
|
||||
console.log("getBrandList onFail", error);
|
||||
};
|
||||
|
||||
TAxios(
|
||||
thunkAPI.dispatch,
|
||||
thunkAPI.getState,
|
||||
"get",
|
||||
URLS.GET_BRAND_LIST,
|
||||
{},
|
||||
{},
|
||||
onSuccess,
|
||||
onFail
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const initialState = {
|
||||
brandInfo: {},
|
||||
};
|
||||
|
||||
export const featuredBrandsSlice = createSlice({
|
||||
name: "featuredBrands",
|
||||
initialState,
|
||||
reducers: {
|
||||
updateBrandInfo: (state, action) => {
|
||||
state.featuredBrandsData = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { updateBrandInfo } = featuredBrandsSlice.actions;
|
||||
|
||||
export default featuredBrandsSlice.reducer;
|
||||
@@ -1,11 +1,12 @@
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
|
||||
import appDataReducer from "../features/appData/appDataSlice";
|
||||
import deviceReducer from "../features/device/deviceSlice";
|
||||
import featuredBrandsReducer from "../features/brand/featuredBrandsSlice";
|
||||
import commonReducer from "../features/common/commonSlice";
|
||||
import panelsReducer from "../features/panels/panelsSlice";
|
||||
import deviceReducer from "../features/device/deviceSlice";
|
||||
import homeReducer from "../features/home/homeSlice";
|
||||
import onSaleReducer from "../features/onSale/onSaleSlice";
|
||||
import panelsReducer from "../features/panels/panelsSlice";
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
@@ -15,5 +16,6 @@ export const store = configureStore({
|
||||
common: commonReducer,
|
||||
home: homeReducer,
|
||||
onSale: onSaleReducer,
|
||||
featuredBrands: featuredBrandsReducer,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user