From 6dd56e451ff0accd100d14a45f04be3b3cc84477 Mon Sep 17 00:00:00 2001 From: junh_eee Date: Wed, 31 Aug 2022 16:03:46 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20-=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/login/actions/authAction.ts | 15 +++- src/modules/account/login/apis/authApi.ts | 5 ++ src/modules/account/login/models/authModel.ts | 18 +++++ .../account/login/reducers/authReducer.ts | 14 +++- src/modules/account/login/sagas/authSaga.ts | 15 ++++ .../design/mypage/myinfo/DesignMyinfo1.js | 80 ++++++++++++------- 6 files changed, 113 insertions(+), 34 deletions(-) diff --git a/src/modules/account/login/actions/authAction.ts b/src/modules/account/login/actions/authAction.ts index d3a734f..55dc0ca 100644 --- a/src/modules/account/login/actions/authAction.ts +++ b/src/modules/account/login/actions/authAction.ts @@ -1,6 +1,6 @@ import { AxiosError } from 'axios'; import { ActionType, createAsyncAction } from 'typesafe-actions'; -import { TokenAccount, UserAccount, UserData } from '../models/authModel'; +import { TokenAccount, UserAccount, UserData, UserPageData } from '../models/authModel'; const USERS_LOGIN_REQUEST = 'auth/USERS_LOGIN_REQUEST'; const USERS_LOGIN_SUCCESS = 'auth/USERS_LOGIN_SUCCESS'; @@ -14,6 +14,10 @@ const USERS_LOGOUT_REQUEST = 'auth/USERS_LOGOUT_REQUEST'; const USERS_LOGOUT_SUCCESS = 'auth/USERS_LOGOUT_SUCCESS'; const USERS_LOGOUT_FAILURE = 'auth/USERS_LOGOUT_FAILURE'; +const USERS_USERPAGE_REQUEST = 'auth/USERS_USERPAGE_REQUEST'; +const USERS_USERPAGE_SUCCESS = 'auth/USERS_USERPAGE_SUCCESS'; +const USERS_USERPAGE_FAILURE = 'auth/USERS_USERPAGE_FAILURE'; + export const login = createAsyncAction( USERS_LOGIN_REQUEST, USERS_LOGIN_SUCCESS, @@ -38,11 +42,18 @@ export const refresh = createAsyncAction( USERS_LOGOUT_FAILURE )(); +export const userPage = createAsyncAction( + USERS_USERPAGE_REQUEST, + USERS_USERPAGE_SUCCESS, + USERS_USERPAGE_FAILURE +)(); + const actions = { login, check, logout, - refresh + refresh, + userPage }; export type AuthAction = ActionType; diff --git a/src/modules/account/login/apis/authApi.ts b/src/modules/account/login/apis/authApi.ts index 98771b1..6a72b42 100644 --- a/src/modules/account/login/apis/authApi.ts +++ b/src/modules/account/login/apis/authApi.ts @@ -17,5 +17,10 @@ export const authAPI = { }, refreshToken: (data: TokenAccount) => { return axios.post('api/acnt/jwt/refresh', data); + }, + + getUserPage: async(id: string) => { + return await axios.get(`api/acnt/cstmr/profile/${id}`); } + }; diff --git a/src/modules/account/login/models/authModel.ts b/src/modules/account/login/models/authModel.ts index c2a9eea..bbe2908 100644 --- a/src/modules/account/login/models/authModel.ts +++ b/src/modules/account/login/models/authModel.ts @@ -56,3 +56,21 @@ export interface UserData { authLevel: string; authNm: string; } + + +export interface UserPageState { + userPage: UserPageData | undefined; +} +export interface UserPageData { + memberName: string; + birthdyDate: string; + genderCd: string; + cntryCd: string; + email: string; + hpno: string; + userId: string; +} + +export const initResponseUserPageData = { + userPage: undefined +} diff --git a/src/modules/account/login/reducers/authReducer.ts b/src/modules/account/login/reducers/authReducer.ts index f596393..45c5afd 100644 --- a/src/modules/account/login/reducers/authReducer.ts +++ b/src/modules/account/login/reducers/authReducer.ts @@ -6,13 +6,14 @@ import { createReducer } from 'typesafe-actions'; // action import { AuthAction, + userPage, check, login, logout, refresh } from '../actions/authAction'; -import { UserData } from '../models/authModel'; +import { UserPageState, UserPageData, initResponseUserPageData, UserData } from '../models/authModel'; export interface AuthState { pageLoading: boolean; @@ -31,6 +32,7 @@ const initialState: AuthState = { message: '' }; + export const authReducer = createReducer(initialState) .handleAction(login.success, (state, action) => produce(state, draft => { @@ -74,3 +76,13 @@ export const authReducer = createReducer(initialState) draft.user = undefined; }) ); + + export const mypageReducer = createReducer( + initResponseUserPageData + ).handleAction(userPage.success, (state, action) => + produce(state, draft => { + const data: UserPageData = action.payload; + + draft.userPage = data; + }) + ) \ No newline at end of file diff --git a/src/modules/account/login/sagas/authSaga.ts b/src/modules/account/login/sagas/authSaga.ts index 65c2297..d8ed7e3 100644 --- a/src/modules/account/login/sagas/authSaga.ts +++ b/src/modules/account/login/sagas/authSaga.ts @@ -125,9 +125,24 @@ function* userLogoutSaga() { } } +function* userPageSaga( + action: ActionType +) { + try{ + const controlId = action.payload; + + const { data } = yield call(authAPI.getUserPage, controlId); + console.log('userPageData : ', data) + yield put(Actions.userPage.success(data)); + } catch (error) { + yield put(Actions.userPage.failure(error)); + } +} + export function* authSaga() { yield takeEvery(Actions.login.request, userLoginSaga); yield takeEvery(Actions.check.request, checkAuthencationSaga); yield takeEvery(Actions.logout.request, userLogoutSaga); // yield takeEvery(Actions.refresh.request, refreshTokenSaga); + yield takeEvery(Actions.userPage.request, userPageSaga); } diff --git a/src/views/design/mypage/myinfo/DesignMyinfo1.js b/src/views/design/mypage/myinfo/DesignMyinfo1.js index 0b42254..df6fe44 100644 --- a/src/views/design/mypage/myinfo/DesignMyinfo1.js +++ b/src/views/design/mypage/myinfo/DesignMyinfo1.js @@ -1,16 +1,18 @@ // ** React Imports import { useState, useEffect } from 'react' import { useParams, Link } from 'react-router-dom' - import { useSelector, useDispatch } from 'react-redux' +import { userPage } from '../../../../modules/account/login/actions/authAction'; // ** Third Party Components import { User, Info, CreditCard, Lock, Check, X } from 'react-feather' -import { Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert, FormGroup, Input, Label, Button, +import { Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert, FormGroup, Form, Input, Label, Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap' // ** Styles import '../../../../assets/css/custom.css'; + + const UserEdit = () => { // ** States & Vars const [activeTab, setActiveTab] = useState('1'), @@ -22,6 +24,16 @@ const UserEdit = () => { const toggle = tab => setActiveTab(tab) const [formModal, setFormModal] = useState(false) + const { user } = useSelector(state => state.authState); + //const { userPage } = useSelector(state => state.UserPageState); + + useEffect(() => { + if(user) { + dispatch(userPage.request(user.cstmrSno)); + } + }, []); + + return (
@@ -56,20 +68,20 @@ const UserEdit = () => { - - + + - - + + - - + + @@ -77,8 +89,8 @@ const UserEdit = () => { - - + + @@ -86,14 +98,14 @@ const UserEdit = () => { - - + + - - + + @@ -106,7 +118,7 @@ const UserEdit = () => { 변경
- +
{ - - + + {/* 발송 버튼을 누르면 남은시간 d-none를 빼주세여~ 그럼나타나여~ */} @@ -145,8 +157,8 @@ const UserEdit = () => { - - + + @@ -181,22 +193,28 @@ const UserEdit = () => {
- - - - + {/* */} +
+ + +
+ {/*
*/} - - - - + {/* */} +
+ + +
+ {/*
*/} - - - - + {/* */} +
+ + +
+ {/*
*/}