diff --git a/src/modules/account/login/sagas/authSaga.ts b/src/modules/account/login/sagas/authSaga.ts index 1761394..b29817a 100644 --- a/src/modules/account/login/sagas/authSaga.ts +++ b/src/modules/account/login/sagas/authSaga.ts @@ -25,7 +25,7 @@ import { Console } from 'console'; function* userLoginSaga(action: ActionType) { const param = action.payload; try { - // console.log('=-==================='); + // console.log('=-==================='); const { data, errorCode } = yield call(authAPI.usersLogin, param); //console.log('>>>>>11>>>>>>>', data); @@ -119,20 +119,19 @@ function* userLogoutSaga() { try { if (accessToken) { - // console.log('dddddddddddddddddddddddddddddddddddd'); + // console.log('dddddddddddddddddddddddddddddddddddd'); const decodedToken = decode(accessToken); const res = yield call(authAPI.usersLogout, decodedToken.cstmrSno); - console.log("res>>>>>>>>",res); - if(res.data=="SUCCESS"){ - location.reload(); - } + console.log('res>>>>>>>>', res); + // if(res.data=="SUCCESS"){ + // location.reload(); + // } } yield put(Actions.logout.success()); cookieStorage.removeCookie(COOKIE_ACCESS_TOKEN); cookieStorage.removeCookie(COOKIE_REFRESH_TOKEN); yield put(replace('/')); - } catch (error) { yield put(Actions.logout.failure(error)); } @@ -141,11 +140,11 @@ function* userLogoutSaga() { function* userPageSaga( action: ActionType ) { - try{ + try { const controlId = action.payload; const { data } = yield call(authAPI.getUserPage, controlId); - // console.log('userPageData : ', data) + // console.log('userPageData : ', data) yield put(Actions.userPageAction.success(data)); } catch (error) { yield put(Actions.userPageAction.failure(error)); @@ -153,80 +152,80 @@ function* userPageSaga( } function* userUpdateSaga( - action: ActionType) { + action: ActionType +) { const param = action.payload; - try{ - const { data,errorCode } = yield call(authAPI.updateUser, param); + try { + const { data, errorCode } = yield call(authAPI.updateUser, param); yield put(Actions.pwUpdateAction.success(data)); - if (data.errorCode==='-1') { + if (data.errorCode === '-1') { yield put( - MessageActions.IS_ERROR({ - errorCode: ERROR_MESSAGE.code, - errorMessage: ERROR_MESSAGE.message, - isHistoryBack: false, - isRefresh: false + MessageActions.IS_ERROR({ + errorCode: ERROR_MESSAGE.code, + errorMessage: ERROR_MESSAGE.message, + isHistoryBack: false, + isRefresh: false }) ); - } - else{ + } else { yield put( - MessageActions.IS_MESSAGE({ - messageCode: SAVE_MESSAGE.code, - message: SAVE_MESSAGE.message, - isHistoryBack: false, - isRefresh: true + MessageActions.IS_MESSAGE({ + messageCode: SAVE_MESSAGE.code, + message: SAVE_MESSAGE.message, + isHistoryBack: false, + isRefresh: true }) ); - } - } catch (error) { + } + } catch (error) { yield put( - MessageActions.IS_ERROR({ + MessageActions.IS_ERROR({ errorCode: ERROR_MESSAGE.code, errorMessage: '처리 중 에러입니다.', isHistoryBack: false, isRefresh: false - }) - ); - } + }) + ); } +} function* userPwSaga( - action: ActionType) { + action: ActionType +) { const param = action.payload; - try{ - const { data,errorCode } = yield call(authAPI.pwupdate, param); + try { + const { data, errorCode } = yield call(authAPI.pwupdate, param); //yield put(Actions.pwUpdateAction.success(data)); - // console.log("saaa",data); - if (data.errorCode==='-1') { + // console.log("saaa",data); + if (data.errorCode === '-1') { yield put( - MessageActions.IS_ERROR({ - errorCode: ERROR_MESSAGE.code, - errorMessage: ERROR_MESSAGE.message, - isHistoryBack: false, - isRefresh: false + MessageActions.IS_ERROR({ + errorCode: ERROR_MESSAGE.code, + errorMessage: ERROR_MESSAGE.message, + isHistoryBack: false, + isRefresh: false }) ); - } - else{ + } else { yield put( - MessageActions.IS_MESSAGE({ - messageCode: SAVE_MESSAGE.code, - message: SAVE_MESSAGE.message, - isHistoryBack: true, - isRefresh: true + MessageActions.IS_MESSAGE({ + messageCode: SAVE_MESSAGE.code, + message: SAVE_MESSAGE.message, + isHistoryBack: true, + isRefresh: true }) ); - } - } catch (error) { + } + } catch (error) { yield put( - MessageActions.IS_ERROR({ + MessageActions.IS_ERROR({ errorCode: ERROR_MESSAGE.code, errorMessage: '비밀번호를 확인해주세요', isHistoryBack: false, isRefresh: false - }) - ); - } + }) + ); } +} // function* updateSaga(action: ActionType) { // try { // const detail = action.payload; diff --git a/src/redux/reducers/rootReducer.ts b/src/redux/reducers/rootReducer.ts index c9e901a..8c22c84 100644 --- a/src/redux/reducers/rootReducer.ts +++ b/src/redux/reducers/rootReducer.ts @@ -14,7 +14,10 @@ import { dronSaga } from '../../modules/basis/dron/sagas/basisDronSaga'; import { groupReducer } from '../../modules/basis/group/reducers/basisGroupReducer'; import { basGroupSaga } from '../../modules/basis/group/sagas/basisGroupSaga'; import { messageReducer } from '../../modules/comn/message/reducers/comnMessageReducer'; -import { mypageReducer, userPwReducer } from '../../modules/account/login/reducers/authReducer'; +import { + mypageReducer, + userPwReducer +} from '../../modules/account/login/reducers/authReducer'; import { findSaga } from '../../modules/account/find/sagas/findSaga'; import { findAccountReducer } from '../../modules/account/find/reducers/findReducer'; @@ -26,7 +29,7 @@ import { controlGpFltPlanReducer, controlGpSaga, ControlGpState, - controlGpLogReducer, + controlGpLogReducer } from '../../modules/control/gp'; import controlMapReducer from '../../modules/control/map/reducers/controlMapReducer'; import { mainDahReducer } from '../../modules/main/dash/reducers/mainDashReducer'; @@ -57,7 +60,7 @@ export function* saga() { yield all([fork(findSaga)]); } -const rootReducer = combineReducers({ +const appReducer = combineReducers({ auth, navbar, layout, @@ -74,13 +77,20 @@ const rootReducer = combineReducers({ controlGpHisState: controlGpHisReducer, controlGpLogState: controlGpLogReducer, controlGpDtlState: controlGpDtlReducer, - controlGroupAuthState: controlGroupAuthReducer, + controlGroupAuthState: controlGroupAuthReducer, controlGpFltPlanState: controlGpFltPlanReducer, menuState: menuReducer, analysisHistoryState: analysisHistoryReducer, analysisSimulatorState: analysisSimulatorReducer, flightState: flightReducer, - findState: findAccountReducer, + findState: findAccountReducer }); +const rootReducer = (state, action) => { + if (action.type === 'auth/USERS_LOGOUT_SUCCESS') { + appReducer(undefined, action); + } + return appReducer(state, action); +}; + export default rootReducer;