SearchPanel 작업 진행 중 - chw

This commit is contained in:
hyunwoo93.cha
2024-01-25 23:17:16 +09:00
parent cdd6a774b6
commit 8110067e29
9 changed files with 195 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import { URLS } from "../../api/apiConfig";
import { TAxios } from "../../api/TAxios";
// 추천 Keyword 목록 조회 IF-LGSP-055
export const getMyRecommandedKeyword = createAsyncThunk(
"myPage/getMyRecommandedKeyword",
async (_, thunkAPI) => {
const onSuccess = (response) => {
console.log("getMyRecommandedKeyword onSuccess ", response.data);
thunkAPI.dispatch(
myPageSlice.actions.updateRecommandedKeywordData(response.data)
);
};
const onFail = (error) => {
console.error("getMyRecommandedKeyword onFail ", error);
};
TAxios(
thunkAPI.dispatch,
thunkAPI.getState,
"get",
URLS.GET_MY_RECOMMANDED_KEYWORD,
{},
{},
onSuccess,
onFail
);
}
);
const initialState = {
recommandedKeywordData: {},
};
export const myPageSlice = createSlice({
name: "myPage",
initialState,
reducers: {
updateRecommandedKeywordData: (state, action) => {
state.recommandedKeywordData = action.payload;
},
},
});
export const { updateRecommandedKeywordData } = myPageSlice.actions;
export default myPageSlice.reducer;