From b3481b4fce30b44a40b53b17541a4582f890f81d Mon Sep 17 00:00:00 2001 From: LEEYONGJAE Date: Wed, 5 Feb 2025 17:44:58 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=A1=9C=EB=94=A9=EB=B0=94=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/auth/AutoLogin.jsx | 24 ++- src/components/auth/Login.jsx | 299 ++++++++++++++++-------------- 2 files changed, 174 insertions(+), 149 deletions(-) diff --git a/src/components/auth/AutoLogin.jsx b/src/components/auth/AutoLogin.jsx index 0d539cbb..d400f2c4 100644 --- a/src/components/auth/AutoLogin.jsx +++ b/src/components/auth/AutoLogin.jsx @@ -1,21 +1,27 @@ 'use client' +import { useState } from 'react' import { useMessage } from '@/hooks/useMessage' +import GlobalSpinner from '@/components/common/spinner/GlobalSpinner' export default function AutoLoginPage() { + const [isLoading, setIsLoading] = useState(true) const { getMessage } = useMessage() return ( -
-
- {getMessage('site.name')} - {getMessage('site.sub_name')} -
-
-
- {getMessage('login.auto.page.text')} + <> + {isLoading && } +
+
+ {getMessage('site.name')} + {getMessage('site.sub_name')} +
+
+
+ {getMessage('login.auto.page.text')} +
-
+ ) } diff --git a/src/components/auth/Login.jsx b/src/components/auth/Login.jsx index eca80361..b23f9c53 100644 --- a/src/components/auth/Login.jsx +++ b/src/components/auth/Login.jsx @@ -10,14 +10,15 @@ import { useMessage } from '@/hooks/useMessage' import { globalLocaleStore } from '@/store/localeAtom' import { sessionStore } from '@/store/commonAtom' import { useRouter } from 'next/navigation' - -import Cookies from 'js-cookie' - import { useSearchParams } from 'next/navigation' +import GlobalSpinner from '@/components/common/spinner/GlobalSpinner' +import Cookies from 'js-cookie' import AutoLogin from './AutoLogin' export default function Login() { + const [isLoading, setIsLoading] = useState(false) + // 자동 로그인 const initParams = useSearchParams() const autoLoginParam = initParams.get('autoLoginParam1') @@ -35,11 +36,13 @@ export default function Login() { }, []) const autoLoginProcess = async (autoLoginParam) => { + setIsLoading(true) await promisePost({ url: '/api/login/v1.0/user/login/autoLoginDecryptData', data: { loginId: autoLoginParam } }) .then((res) => { if (res) { if (res.data) { post({ url: '/api/login/v1.0/user', data: { loginId: res.data } }).then((response) => { + setIsLoading(false) if (response) { const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' } setSession(result) @@ -53,6 +56,7 @@ export default function Login() { } }) .catch((error) => { + setIsLoading(false) router.push('/login') }) } @@ -93,9 +97,11 @@ export default function Login() { loginId: formData.get('id'), pwd: formData.get('password'), } + setIsLoading(true) await promisePost({ url: '/api/login/v1.0/login', data: param }) .then((res) => { if (res) { + setIsLoading(false) if (res.data.result.resultCode === 'S') { setSession(res.data.data) setSessionState(res.data.data) @@ -105,7 +111,6 @@ export default function Login() { } else { Cookies.remove('chkLoginId') } - // router.push('/') login() } else { alert(res.data.result.resultMsg) @@ -113,6 +118,7 @@ export default function Login() { } }) .catch((error) => { + setIsLoading(false) alert(error.response.data.message) }) } @@ -123,12 +129,14 @@ export default function Login() { loginId: checkId, email: checkEmail, } + setIsLoading(true) await promisePatch({ url: '/api/login/v1.0/user/init-password', data: param, }) .then((res) => { if (res) { + setIsLoading(false) if (res.data.result.resultCode == 'S') { alert(getMessage('login.init_password.complete_message')) setCheckId('') @@ -140,36 +148,135 @@ export default function Login() { } }) .catch((error) => { + setIsLoading(false) alert(error.response.data.message) }) } return ( -
-
- - react - - {!autoLoginParam && passwordReset === 1 && ( - <> -
-
-
- {getMessage('site.name')} - {getMessage('site.sub_name')} + <> + {isLoading && } +
+
+ + react + + {!autoLoginParam && passwordReset === 1 && ( + <> +
+ +
+ {getMessage('site.name')} + {getMessage('site.sub_name')} +
+
+
+ { + setUserId(e.target.value) + }} + onFocus={() => setIdFocus(true)} + onBlur={() => setIdFocus(false)} + /> + +
+
+ { + setPasswordVisible(passwordVisible) + }} + onFocus={() => setSecFocus(true)} + onBlur={() => setSecFocus(false)} + /> + +
+
+ { + setChkLoginId(e.target.checked) + }} + /> + +
+
+ +
+
+ +
+
+ +
+
+ + {getMessage('login.guide.text')} +
+ {getMessage('login.guide.sub1')} {getMessage('login.guide.join.btn')} + {getMessage('login.guide.sub2')} +
+ + )} + {!autoLoginParam && passwordReset === 2 && ( + <> +
+
+ {getMessage('login.init_password.title')} + {getMessage('login.init_password.sub_title')}
{ - setUserId(e.target.value) + setCheckId(e.target.value) }} onFocus={() => setIdFocus(true)} onBlur={() => setIdFocus(false)} @@ -177,146 +284,58 @@ export default function Login() {
-
+
{ - setPasswordVisible(passwordVisible) + setCheckEmail(e.target.value) }} + placeholder={getMessage('login.init_password.email.placeholder')} onFocus={() => setSecFocus(true)} onBlur={() => setSecFocus(false)} />
-
- { - setChkLoginId(e.target.checked) +
+
-
- -
-
-
- -
-
- - {getMessage('login.guide.text')} -
- {getMessage('login.guide.sub1')} {getMessage('login.guide.join.btn')} - {getMessage('login.guide.sub2')} -
- - )} - {!autoLoginParam && passwordReset === 2 && ( - <> -
-
- {getMessage('login.init_password.title')} - {getMessage('login.init_password.sub_title')}
-
-
- { - setCheckId(e.target.value) - }} - onFocus={() => setIdFocus(true)} - onBlur={() => setIdFocus(false)} - /> - -
-
- { - setCheckEmail(e.target.value) - }} - placeholder={getMessage('login.init_password.email.placeholder')} - onFocus={() => setSecFocus(true)} - onBlur={() => setSecFocus(false)} - /> - -
-
- - -
-
-
- - )} - {autoLoginParam && } + + )} + {autoLoginParam && } +
+
COPYRIGHT©2024 Hanwha Japan All Rights Reserved.
-
COPYRIGHT©2024 Hanwha Japan All Rights Reserved.
-
+ ) }