53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
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;
|