From 6dfb068fe216ab72f0f6e28666303706c5a302f0 Mon Sep 17 00:00:00 2001 From: sanguu Date: Tue, 6 Sep 2022 10:52:30 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80-?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/mypage/AccountMypageForm.js | 181 ++++++++++++++++-- .../account/register/AccountRegisterForm.js | 1 - .../account/mypage/AccountMypageContainer.js | 24 ++- .../account/login/actions/authAction.ts | 4 +- src/modules/account/login/apis/authApi.ts | 8 +- src/modules/account/login/models/authModel.ts | 12 +- .../account/login/reducers/authReducer.ts | 1 + src/modules/account/login/sagas/authSaga.ts | 41 +++- 8 files changed, 246 insertions(+), 26 deletions(-) diff --git a/src/components/account/mypage/AccountMypageForm.js b/src/components/account/mypage/AccountMypageForm.js index 03036f4..e270d3b 100644 --- a/src/components/account/mypage/AccountMypageForm.js +++ b/src/components/account/mypage/AccountMypageForm.js @@ -8,12 +8,148 @@ import { // ** Styles import '../../../assets/css/custom.css'; - +import { accountApi } from '../../../modules/account/register/apis/accountApi'; //import {UserPageState,UserPageData,initResponseUserPageData} from '../../../../modules/account/login/models/authModel'; //const [detailData, setDetailData] = useState(userPage.UserPageData); -const AccountMypageForm = ({ userInfo, handler, formModal,handlerUpdate}) => { +const AccountMypageForm = ({ userInfo, handler, formModal,handlerUpdate,handlerInput}) => { + const [isRunning, setIsRunning] = useState(false); + const [sendCount, setSendCount] = useState(0); + const [isCrtfy, setIsCrtfy] = useState(false); + const [minutes_Counter, setMinutes_Counter] = useState('03'); + const [seconds_Counter, setSeconds_Counter] = useState('00'); + const [timer, setTimer] = useState(null); + const [modal, setModal] = useState({ + isOpen: false, + title: '', + desc: '' + }); + + const timerStart = count => { + let minutes, seconds; + + const timer = setInterval(() => { + setIsRunning(true); + minutes = parseInt(count / 60, 10); + seconds = parseInt(count % 60, 10); + minutes = minutes < 10 ? '0' + minutes : minutes; + seconds = seconds < 10 ? '0' + seconds : seconds; + setMinutes_Counter(minutes); + setSeconds_Counter(seconds); + + //타이머 끝 + if (--count < 0) { + clearInterval(timer); + setIsRunning(false); + setValue('crtfyNo', ''); + // setCrtfyNo(''); + } + }, 1000); + + setTimer(timer); + + return () => { + clearInterval(timer); + }; + }; + //휴대폰 인증번호 보내기 + const handlerSmsSend = async () => { + // const vData = getValues(); + + if (!userInfo.clncd || !userInfo.hpno) { + setModal({ + isOpen: true, + title: '인증번호 발송', + desc: '휴대폰 번호를 입력 해주세요.' + }); + return; + } + + if (sendCount >= 3) { + setModal({ + isOpen: true, + title: '인증번호 발송', + desc: '인증번호 발송은 3회 까지만 가능합니다.' + }); + return; + } + + const res = await accountApi.crtfyhp(userInfo.hpno); + + if (!res.data.result) { + if (res.data.code === -1) { + setModal({ + isOpen: true, + title: '인증번호 발송', + desc: '이미 가입된 휴대폰 입니다.' + }); + } else { + setModal({ + isOpen: true, + title: '인증번호 발송', + desc: '인증번호 발송을 실패하였습니다.' + }); + } + return; + } + // console.log(res); + if (isRunning) { + clearInterval(timer); + } + setIsRunning(true); + setSendCount(sendCount + 1); + timerStart(180); + + // handlerSmsSend(); + }; + useEffect(() => { + // console.log('isRunning>>>', isRunning); + if (isRunning) { + clearInterval(timer); + } else { + // handlerSmsSend(); + } + + return () => { + clearInterval(timer); + }; + }, []); + //휴대폰 인증하기 + const handlerSmsConfirm = async () => { + //const vData = getValues(); + + if (!userInfo.clncd || !userInfo.hpno) { + setModal({ + isOpen: true, + title: '인증번호 인증', + desc: '휴대폰 번호를 입력 해주세요.' + }); + + return false; + } + if (!userInfo.crtfyNo) { + setModal({ + isOpen: true, + title: '인증번호 인증', + desc: '인증번호 를 입력 해주세요.' + }); + return false; + } + + const res = await accountApi.crtfyhpConfirm(vData.hpno, vData.crtfyNo); + + if (!res.data.result) { + setModal({ + isOpen: true, + title: '인증번호 인증', + desc: '인증번호 가 잘못 되었습니다.' + }); + return; + } + setIsRunning(true); + setIsCrtfy(true); + }; return ( @@ -55,18 +191,18 @@ const AccountMypageForm = ({ userInfo, handler, formModal,handlerUpdate}) => { - + - + -