김장현
11 months ago
7 changed files with 106 additions and 3 deletions
@ -0,0 +1,21 @@
|
||||
import { AxiosError } from 'axios'; |
||||
import { createAsyncAction, ActionType, createAction } from 'typesafe-actions'; |
||||
|
||||
import { IQnaAdminSearch, IQnaAdminList } from '../model'; |
||||
|
||||
// 목록 조회
|
||||
const ADMIN_LIST_REQUEST = 'cstmrService/qna/ADMIN_LIST_REQUEST'; |
||||
const ADMIN_LIST_SUCCESS = 'cstmrService/qna/ADMIN_LIST_SUCCESS'; |
||||
const ADMIN_LIST_FAILURE = 'cstmrService/qna/ADMIN_LIST_FAILURE'; |
||||
|
||||
export const ADMIN_LIST = createAsyncAction( |
||||
ADMIN_LIST_REQUEST, |
||||
ADMIN_LIST_SUCCESS, |
||||
ADMIN_LIST_FAILURE |
||||
)<IQnaAdminSearch, IQnaAdminList[], AxiosError>(); |
||||
|
||||
const actions = { |
||||
ADMIN_LIST |
||||
}; |
||||
|
||||
export type QnaAction = ActionType<typeof actions>; |
@ -0,0 +1,11 @@
|
||||
import axios from '../../../utils/customAxiosUtil'; |
||||
|
||||
export const qnaAPI = { |
||||
adminList: async ({ category, searchType, word }) => { |
||||
// const url =
|
||||
// category === '전체'
|
||||
// ? `api/bas/cns/faq?word=${word}`
|
||||
// : `api/bas/cns/faq?category=${category}&word=${word}`;
|
||||
return await axios.get(``); |
||||
} |
||||
}; |
@ -0,0 +1,11 @@
|
||||
export interface IQnaState { |
||||
adminList: []; |
||||
} |
||||
|
||||
export interface IQnaAdminList {} |
||||
|
||||
export interface IQnaAdminSearch { |
||||
category: string; |
||||
searchType: string; |
||||
word: string; |
||||
} |
@ -0,0 +1,15 @@
|
||||
import { createReducer } from 'typesafe-actions'; |
||||
import produce from 'immer'; |
||||
import * as Actions from '../action'; |
||||
import { IQnaState } from '../model'; |
||||
|
||||
export const faqReducer = createReducer<IQnaState, Actions.QnaAction>({ |
||||
adminList: [] |
||||
}) |
||||
// 목록
|
||||
.handleAction(Actions.ADMIN_LIST.success, (state, action) => |
||||
produce(state, draft => { |
||||
const data = action.payload; |
||||
// draft.adminList = data;
|
||||
}) |
||||
); |
@ -0,0 +1,40 @@
|
||||
import { call, put, takeEvery } from '@redux-saga/core/effects'; |
||||
import { ActionType } from 'typesafe-actions'; |
||||
import { |
||||
DELETE_MESSAGE, |
||||
DUPLATE_MESSAGE, |
||||
ERROR_MESSAGE, |
||||
SAVE_MESSAGE |
||||
} from '../../../../configs/constants'; |
||||
import * as MessageActions from '../../../comn/message/actions/comnMessageAction'; |
||||
import * as Actions from '../action'; |
||||
import * as Apis from '../apis'; |
||||
|
||||
function* adminListSaga(action: ActionType<typeof Actions.ADMIN_LIST.request>) { |
||||
try { |
||||
const payload = action.payload; |
||||
const res = yield call(Apis.qnaAPI.adminList, payload); |
||||
const { data, count, errorCode } = res; |
||||
|
||||
if (errorCode) { |
||||
// 오류메시지 호출
|
||||
yield put( |
||||
MessageActions.IS_ERROR({ |
||||
errorCode: errorCode, |
||||
errorMessage: '처리중 오류가 발생하였습니다', |
||||
isHistoryBack: false, |
||||
isRefresh: false |
||||
}) |
||||
); |
||||
|
||||
return; |
||||
} |
||||
yield put(Actions.ADMIN_LIST.success(data)); |
||||
} catch (error) { |
||||
yield put(Actions.ADMIN_LIST.failure(error)); |
||||
} |
||||
} |
||||
|
||||
export function* faqSaga() { |
||||
yield takeEvery(Actions.ADMIN_LIST.request, adminListSaga); |
||||
} |
Loading…
Reference in new issue