From 412db26677c418ce08130b24824d2b0240298ff6 Mon Sep 17 00:00:00 2001 From: "younghoon100.park" Date: Thu, 25 Jan 2024 17:31:12 +0900 Subject: [PATCH] =?UTF-8?q?[OnSalePanel]=20API=20=EA=B5=AC=EC=A1=B0=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=97=85?= =?UTF-8?q?=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/onsaleController/onSaleSlice.js 생성 및 logic 추가 (store 추가완료) 2. OnSalePanel.jsx, CategoryNav.jsx logic 및 props 변경 3. api/apiConfig.js brand-controller URLS 추가 P.S : api/onSaleApi.js 파일은 현재 다른 곳에서 사용중이라 해당 commit에서는 삭제하지 않았습니다. --- com.twin.app.shoptime/src/App/App.js | 2 + .../src/features/onSale/onSaleSlice.js | 51 +++++++++ com.twin.app.shoptime/src/store/store.js | 2 + .../OnSalePanel/CategoryNav/CategoryNav.jsx | 11 +- .../src/views/OnSalePanel/OnSalePanel.jsx | 102 +++++++----------- .../views/OnSalePanel/OnSalePanel.module.less | 2 - 6 files changed, 100 insertions(+), 70 deletions(-) create mode 100644 com.twin.app.shoptime/src/features/onSale/onSaleSlice.js diff --git a/com.twin.app.shoptime/src/App/App.js b/com.twin.app.shoptime/src/App/App.js index e11c6094..b999aa47 100644 --- a/com.twin.app.shoptime/src/App/App.js +++ b/com.twin.app.shoptime/src/App/App.js @@ -7,6 +7,7 @@ import MainView from "../views/MainView/MainView"; import { useDispatch } from "react-redux"; import { getAuthenticationCode } from "../features/device/deviceSlice"; import { getHomeMenu } from "../features/home/homeSlice"; +import { getOnSaleInfo } from "../features/onSale/onSaleSlice"; function AppBase(props) { const dispatch = useDispatch(); @@ -14,6 +15,7 @@ function AppBase(props) { useEffect(() => { dispatch(getAuthenticationCode()); dispatch(getHomeMenu()); + dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" })); }, [dispatch]); return ; diff --git a/com.twin.app.shoptime/src/features/onSale/onSaleSlice.js b/com.twin.app.shoptime/src/features/onSale/onSaleSlice.js new file mode 100644 index 00000000..060b88ed --- /dev/null +++ b/com.twin.app.shoptime/src/features/onSale/onSaleSlice.js @@ -0,0 +1,51 @@ +import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; + +import { URLS } from "../../api/apiConfig"; +import { TAxios } from "../../api/TAxios"; + +// On Sale 조회 IF-LGSP-086 +export const getOnSaleInfo = createAsyncThunk( + "onSale/getOnSaleInfo", + + async (props, thunkAPI) => { + const { categoryIncFlag, lgCatCd } = props; + const onSuccess = (response) => { + console.log("getOnSaleInfo onSuccess ", response.data); + + thunkAPI.dispatch(onSaleSlice.actions.updateOnSaleData(response.data.data)); + }; + + const onFail = (error) => { + console.log("getOnSaleInfo onFail", error); + }; + + TAxios( + thunkAPI.dispatch, + thunkAPI.getState, + "get", + URLS.GET_ON_SALE_INFO, + { categoryIncFlag, lgCatCd }, + {}, + onSuccess, + onFail + ); + } +); + +const initialState = { + onSaleData: {}, +}; + +export const onSaleSlice = createSlice({ + name: "onSale", + initialState, + reducers: { + updateOnSaleData: (state, action) => { + state.onSaleData = action.payload; + }, + }, +}); + +export const { updateOnSaleData } = onSaleSlice.actions; + +export default onSaleSlice.reducer; diff --git a/com.twin.app.shoptime/src/store/store.js b/com.twin.app.shoptime/src/store/store.js index 25e0d76f..0b987def 100644 --- a/com.twin.app.shoptime/src/store/store.js +++ b/com.twin.app.shoptime/src/store/store.js @@ -5,6 +5,7 @@ import deviceReducer from "../features/device/deviceSlice"; import commonReducer from "../features/common/commonSlice"; import panelsReducer from "../features/panels/panelsSlice"; import homeReducer from "../features/home/homeSlice"; +import onSaleReducer from "../features/onSale/onSaleSlice"; export const store = configureStore({ reducer: { @@ -13,5 +14,6 @@ export const store = configureStore({ appData: appDataReducer, common: commonReducer, home: homeReducer, + onSale: onSaleReducer, }, }); diff --git a/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx b/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx index 84316bdb..f9a12398 100644 --- a/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx +++ b/com.twin.app.shoptime/src/views/OnSalePanel/CategoryNav/CategoryNav.jsx @@ -17,7 +17,7 @@ const SpottableComponent = Spottable("li"); export default function CategoryNav({ categoryInfos, - currentLgCatCdIndex, + currentLgCatCd, onCategoryNavClick, ...rest }) { @@ -31,15 +31,12 @@ export default function CategoryNav({ >