Browse Source

마이페이지 reducer 작업

ctrlDraw
김장현 2 years ago
parent
commit
e960209157
  1. 12
      src/containers/account/mypage/AccountMypageContainer.js
  2. 2
      src/modules/account/login/actions/authAction.ts
  3. 6
      src/modules/account/login/models/authModel.ts
  4. 22
      src/modules/account/login/reducers/authReducer.ts

12
src/containers/account/mypage/AccountMypageContainer.js

@ -43,12 +43,14 @@ import { ConfirmModal } from '../../../components/modal/ConfirmModal';
// ** Function to toggle tabs // ** Function to toggle tabs
const AccountMypageContainer = () => { const AccountMypageContainer = () => {
const [activeTab, setActiveTab] = useState('1'), const [activeTab, setActiveTab] = useState('1');
store = useSelector(state => state.users), const dispatch = useDispatch();
dispatch = useDispatch(), // { id } = useParams();
{ id } = useParams();
const toggle = tab => setActiveTab(tab); const toggle = tab => {
console.log(tab);
return setActiveTab(tab);
};
const [formModal, setFormModal] = useState(false); const [formModal, setFormModal] = useState(false);
const { userPage } = useSelector(state => state.UserPageState); const { userPage } = useSelector(state => state.UserPageState);
const { user } = useSelector(state => state.authState); const { user } = useSelector(state => state.authState);

2
src/modules/account/login/actions/authAction.ts

@ -97,7 +97,7 @@ export const pwCheckAction = createAsyncAction(
USERS_PWCheck_REQUEST, USERS_PWCheck_REQUEST,
USERS_PWCheck_SUCCESS, USERS_PWCheck_SUCCESS,
USERS_PWCheck_FAILURE USERS_PWCheck_FAILURE
)<string, UserPwCheck, AxiosError>(); )<string, boolean, AxiosError>();
const actions = { const actions = {
login, login,

6
src/modules/account/login/models/authModel.ts

@ -60,7 +60,8 @@ export interface UserData {
} }
export interface UserPageState { export interface UserPageState {
userPage: UserPageData | undefined; userPage?: UserPageData | undefined;
result: boolean | undefined;
} }
export interface UserPageData { export interface UserPageData {
memberName: string; memberName: string;
@ -97,5 +98,6 @@ export const initResponseUserPwPageData = {
}; };
export const initResponseUserPageData = { export const initResponseUserPageData = {
userPage: undefined userPage: undefined,
result: undefined
}; };

22
src/modules/account/login/reducers/authReducer.ts

@ -96,21 +96,23 @@ export const authReducer = createReducer<AuthState, AuthAction>(initialState)
draft.isLogin = false; draft.isLogin = false;
draft.user = undefined; draft.user = undefined;
}) })
);
export const mypageReducer = createReducer<UserPageState, AuthAction>(
initResponseUserPageData
)
.handleAction(userPageAction.success, (state, action) =>
produce(state, draft => {
const data: UserPageData = action.payload;
draft.userPage = data;
})
) )
.handleAction(pwCheckAction.success, (state, action) => .handleAction(pwCheckAction.success, (state, action) =>
produce(state, draft => { produce(state, draft => {
const data: UserPwCheck = action.payload; const data = action.payload;
draft.UserPwCheck = data; draft.result = data;
}) })
); );
export const mypageReducer = createReducer<UserPageState, AuthAction>(
initResponseUserPageData
).handleAction(userPageAction.success, (state, action) =>
produce(state, draft => {
const data: UserPageData = action.payload;
draft.userPage = data;
})
);
export const userPwReducer = createReducer<UserPwState, AuthAction>( export const userPwReducer = createReducer<UserPwState, AuthAction>(
initResponseUserPwPageData initResponseUserPwPageData
).handleAction(pwUpdateAction.success, (state, action) => ).handleAction(pwUpdateAction.success, (state, action) =>

Loading…
Cancel
Save