From f1852ef19b93ddf3a115d291c91f080caf85356a Mon Sep 17 00:00:00 2001 From: jangheon Pyo Date: Mon, 29 Jan 2024 10:04:30 +0900 Subject: [PATCH] =?UTF-8?q?[product]=C2=A0=20bestSeller=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=B6=94=EA=B0=80=20=EC=82=AC=ED=95=AD=20=C2=A0?= =?UTF-8?q?=C2=A0=20=C2=A0=20Detail=20Notes=20:=201.=20productSlice.js=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=202.=20apiconfig.js=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9=20=EC=B6=94=EA=B0=80=203.=20App.js=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EB=82=B4=EC=9A=A9=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?4.=20Store.js=20=ED=8C=8C=EC=9D=BC=20=EB=82=B4=EC=9A=A9=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.twin.app.shoptime/src/App/App.js | 2 + com.twin.app.shoptime/src/api/apiConfig.js | 3 ++ .../src/features/product/productSlice.js | 49 +++++++++++++++++++ com.twin.app.shoptime/src/store/store.js | 2 + 4 files changed, 56 insertions(+) create mode 100644 com.twin.app.shoptime/src/features/product/productSlice.js diff --git a/com.twin.app.shoptime/src/App/App.js b/com.twin.app.shoptime/src/App/App.js index 5b7149f8..1fd56dec 100644 --- a/com.twin.app.shoptime/src/App/App.js +++ b/com.twin.app.shoptime/src/App/App.js @@ -10,6 +10,7 @@ import { getHomeMenu } from "../features/home/homeSlice"; import { getMyRecommandedKeyword } from "../features/mypage/myPageSlice"; import { getOnSaleInfo } from "../features/onSale/onSaleSlice"; import { getSubCategory } from "../features/main/mainSlice"; +import { getBestSeller } from "../features/product/productSlice"; import MainView from "../views/MainView/MainView"; import css from "./App.module.less"; @@ -22,6 +23,7 @@ function AppBase(props) { dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" })); dispatch(getBrandList()); dispatch(getMyRecommandedKeyword()); + dispatch(getBestSeller()); dispatch( getSubCategory({ lgCatCd: "1000", diff --git a/com.twin.app.shoptime/src/api/apiConfig.js b/com.twin.app.shoptime/src/api/apiConfig.js index 8ec7b9cb..213f6a80 100644 --- a/com.twin.app.shoptime/src/api/apiConfig.js +++ b/com.twin.app.shoptime/src/api/apiConfig.js @@ -28,6 +28,9 @@ export const URLS = { //on-sale controller GET_ON_SALE_INFO: "/lgsp/v1/onsale/onsale.lge", + //product controller + GET_PRODUCT_BESTSELLER: "/lgsp/v1/product/bestSeller.lge", + //my-page controller GET_MY_RECOMMANDED_KEYWORD: "/lgsp/v1/mypage/reckeyword.lge", diff --git a/com.twin.app.shoptime/src/features/product/productSlice.js b/com.twin.app.shoptime/src/features/product/productSlice.js new file mode 100644 index 00000000..12919e28 --- /dev/null +++ b/com.twin.app.shoptime/src/features/product/productSlice.js @@ -0,0 +1,49 @@ +import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; +import { URLS } from "../../api/apiConfig"; +import { TAxios } from "../../api/TAxios"; + +// Best Seller 상품 목록 조회 IF-LGSP-303 +export const getBestSeller = createAsyncThunk( + "bestSeller/getBestSeller", + async (_, thunkAPI) => { + const onSuccess = (response) => { + console.log("getBestSeller onSuccess", response.data); + + thunkAPI.dispatch( + productSlice.actions.updateBestSellerData(response.data.data) + ); + }; + + const onFail = (error) => { + console.log("getBestSeller onFail", error); + }; + + TAxios( + thunkAPI.dispatch, + thunkAPI.getState, + "get", + URLS.GET_PRODUCT_BESTSELLER, + {}, + {}, + onSuccess, + onFail + ); + } +); + +const initialState = { + bestSellerData: {}, +}; + +export const productSlice = createSlice({ + name: "product", + initialState, + reducers: { + updateBestSellerData: (state, action) => { + state.bestSellerData = action.payload; + }, + }, +}); + +export const { updateBestSellerData } = productSlice.actions; +export default productSlice.reducer; diff --git a/com.twin.app.shoptime/src/store/store.js b/com.twin.app.shoptime/src/store/store.js index a0354a6a..8d2e7fc8 100644 --- a/com.twin.app.shoptime/src/store/store.js +++ b/com.twin.app.shoptime/src/store/store.js @@ -7,6 +7,7 @@ import deviceReducer from "../features/device/deviceSlice"; import homeReducer from "../features/home/homeSlice"; import myPageReducer from "../features/mypage/myPageSlice"; import onSaleReducer from "../features/onSale/onSaleSlice"; +import productReducer from "../features/product/productSlice"; import panelsReducer from "../features/panels/panelsSlice"; import mainReducer from "../features/main/mainSlice"; @@ -20,6 +21,7 @@ export const store = configureStore({ onSale: onSaleReducer, brand: brandReducer, myPage: myPageReducer, + product: productReducer, main: mainReducer, }, });