Browse Source

마이페이지 reducer 작업

pull/2/head
김장현 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
const AccountMypageContainer = () => {
const [activeTab, setActiveTab] = useState('1'),
store = useSelector(state => state.users),
dispatch = useDispatch(),
{ id } = useParams();
const [activeTab, setActiveTab] = useState('1');
const dispatch = useDispatch();
// { id } = useParams();
const toggle = tab => setActiveTab(tab);
const toggle = tab => {
console.log(tab);
return setActiveTab(tab);
};
const [formModal, setFormModal] = useState(false);
const { userPage } = useSelector(state => state.UserPageState);
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_SUCCESS,
USERS_PWCheck_FAILURE
)<string, UserPwCheck, AxiosError>();
)<string, boolean, AxiosError>();
const actions = {
login,

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

@ -60,7 +60,8 @@ export interface UserData {
}
export interface UserPageState {
userPage: UserPageData | undefined;
userPage?: UserPageData | undefined;
result: boolean | undefined;
}
export interface UserPageData {
memberName: string;
@ -97,5 +98,6 @@ export const initResponseUserPwPageData = {
};
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.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) =>
produce(state, draft => {
const data: UserPwCheck = action.payload;
draft.UserPwCheck = data;
const data = action.payload;
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>(
initResponseUserPwPageData
).handleAction(pwUpdateAction.success, (state, action) =>

Loading…
Cancel
Save