From c919e0b1308fdbbe2ee9e4d71a2926994f4bab21 Mon Sep 17 00:00:00 2001 From: "younghoon100.park" Date: Thu, 25 Jan 2024 20:47:32 +0900 Subject: [PATCH] =?UTF-8?q?[FeaturedBrandsPanel]=20API=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detail Notes : 1. features/brand/featuredBrnadsSlice.js 생성 및 logic 추가 (store 추가완료) 2. api/apiConfig.js brand-controller URLS 추가 P.S : api/featuredBrandsApi.js 파일은 해당 영역의 panel에서 구조 변경 후 삭제하겠습니다. --- com.twin.app.shoptime/src/App/App.js | 11 ++-- com.twin.app.shoptime/src/api/apiConfig.js | 5 ++ .../src/features/brand/featuredBrandsSlice.js | 51 +++++++++++++++++++ com.twin.app.shoptime/src/store/store.js | 6 ++- 4 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 com.twin.app.shoptime/src/features/brand/featuredBrandsSlice.js diff --git a/com.twin.app.shoptime/src/App/App.js b/com.twin.app.shoptime/src/App/App.js index b999aa47..62d27233 100644 --- a/com.twin.app.shoptime/src/App/App.js +++ b/com.twin.app.shoptime/src/App/App.js @@ -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 ; diff --git a/com.twin.app.shoptime/src/api/apiConfig.js b/com.twin.app.shoptime/src/api/apiConfig.js index 278a5d0e..43f2a1d2 100644 --- a/com.twin.app.shoptime/src/api/apiConfig.js +++ b/com.twin.app.shoptime/src/api/apiConfig.js @@ -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", diff --git a/com.twin.app.shoptime/src/features/brand/featuredBrandsSlice.js b/com.twin.app.shoptime/src/features/brand/featuredBrandsSlice.js new file mode 100644 index 00000000..22daa224 --- /dev/null +++ b/com.twin.app.shoptime/src/features/brand/featuredBrandsSlice.js @@ -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; diff --git a/com.twin.app.shoptime/src/store/store.js b/com.twin.app.shoptime/src/store/store.js index 0b987def..812e8de8 100644 --- a/com.twin.app.shoptime/src/store/store.js +++ b/com.twin.app.shoptime/src/store/store.js @@ -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, }, });