diff --git a/src/app/[locale]/join/complete/page.jsx b/src/app/[locale]/join/complete/page.jsx new file mode 100644 index 00000000..3c5c61c3 --- /dev/null +++ b/src/app/[locale]/join/complete/page.jsx @@ -0,0 +1,19 @@ +'use client' + +import { useI18n } from '@/locales/client' + +export default function CompletePage() { + const t = useI18n() + + return ( + <> +
+

{t('join.complete.title')}

+
{t('join.complete.contents')}
+
+ {t('join.complete.email_comment')} : {t('join.complete.email')} +
+
+ + ) +} diff --git a/src/app/[locale]/join/page.jsx b/src/app/[locale]/join/page.jsx new file mode 100644 index 00000000..118a25b4 --- /dev/null +++ b/src/app/[locale]/join/page.jsx @@ -0,0 +1,5 @@ +import Join from '@/components/auth/Join' + +export default function JoinPage() { + return <>{} +} diff --git a/src/app/[locale]/login/page.jsx b/src/app/[locale]/login/page.jsx index 0686da2e..47a23986 100644 --- a/src/app/[locale]/login/page.jsx +++ b/src/app/[locale]/login/page.jsx @@ -1,9 +1,16 @@ import Login from '@/components/auth/Login' +import { getCurrentLocale } from '@/locales/server' export default function LoginPage() { + const currentLocale = getCurrentLocale() + + const loginPageProps = { + currentLocale, + } + return ( <> - + ) } diff --git a/src/components/Main.jsx b/src/components/Main.jsx index 554c7e8b..4b589106 100644 --- a/src/components/Main.jsx +++ b/src/components/Main.jsx @@ -3,6 +3,7 @@ import { logout } from '@/lib/authActions' import { useChangeLocale, useI18n } from '@/locales/client' import { Button, Chip } from '@nextui-org/react' +import Link from 'next/link' export default function MainPage(props) { const { currentLocale, isLoggedIn } = props @@ -34,6 +35,13 @@ export default function MainPage(props) { )} + {!isLoggedIn && ( +
+ + + +
+ )}
font-test
) diff --git a/src/components/auth/Join.jsx b/src/components/auth/Join.jsx new file mode 100644 index 00000000..971c30a0 --- /dev/null +++ b/src/components/auth/Join.jsx @@ -0,0 +1,321 @@ +'use client' + +import { post } from '@/lib/Axios' +import { redirect } from 'next/navigation' +import { useI18n } from '@/locales/client' + +export default function Join() { + const t = useI18n() + + const joinProcess = async (formData) => { + const param = { + langCd: 'JA', + lastEditUser: formData.get('userId'), + storeQcastNm: formData.get('storeQcastNm'), + storeQcastNmKana: formData.get('storeQcastNmKana'), + postCd: formData.get('postCd'), + addr: formData.get('addr'), + telNo: formData.get('telNo'), + fax: formData.get('fax'), + payTermsCd: 'JB02', + kamId: 'E1101011', + qtCompNm: formData.get('qtCompNm'), + qtPostCd: formData.get('qtPostCd'), + qtAddr: formData.get('qtAddr'), + qtTelNo: formData.get('qtTelNo'), + qtFax: formData.get('qtFax'), + userInfo: { + userId: formData.get('userId'), + userNm: formData.get('userNm'), + userNmKana: formData.get('userNmKana'), + telNo: formData.get('userTelNo'), + fax: formData.get('userFax'), + email: formData.get('email'), + category: formData.get('category'), + }, + } + + await post({ url: '/api/login/v1.0/user/join', data: param }).then((res) => { + if (res) { + if (res.result.resultCode == 'S') { + redirect('/join/complete') + } else { + alert(res.result.resultMsg) + } + } + }) + } + + return ( +
+

{t('join.title')}

+
+
+
+ ● {t('join.sub1.title')} (*{t('common.require')}) {t('join.sub1.comment')} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t('join.sub1.storeQcastNm')} * + +
{t('join.sub1.storeQcastNmKana')} * + +
+ {t('join.sub1.postCd')}/{t('join.sub1.addr')} * + + + +
{t('join.sub1.telNo')} * + +
{t('join.sub1.fax')} * + +
+ +
+ ● {t('join.sub2.title')} (*{t('common.require')}) +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t('join.sub2.userNm')} * + +
{t('join.sub2.userNmKana')} * + +
{t('join.sub2.userId')} * + +
{t('join.sub2.email')} * + +
{t('join.sub2.telNo')} * + +
{t('join.sub2.fax')} * + +
{t('join.sub2.category')} + +
+ +
+ ● {t('join.sub3.title')} (*{t('common.require')}) +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t('join.sub3.qtCompNm')} + +
+ {t('join.sub3.qtPostCd')}/{t('join.sub3.qtAddr')} + + + +
{t('join.sub3.qtEmail')} + +
{t('join.sub3.qtTelNo')} + +
{t('join.sub3.qtFax')} + +
+
+
+ +
+
+
+ ) +} diff --git a/src/components/auth/Login.jsx b/src/components/auth/Login.jsx index 72363367..1d75d69a 100644 --- a/src/components/auth/Login.jsx +++ b/src/components/auth/Login.jsx @@ -1,21 +1,127 @@ 'use client' -import { login } from '@/lib/authActions' +import { post, patch } from '@/lib/Axios' +import { setSession } from '@/lib/authActions' +import { redirect } from 'next/navigation' +import { useI18n } from '@/locales/client' -export default function Login() { - return ( -
-
-
- Your Company -

Sign in to your account

+import { Button } from '@nextui-org/react' +import { useRecoilState } from 'recoil' +import { modalContent, modalState } from '@/store/modalAtom' + +export default function Login(props) { + const { currentLocale } = props + const t = useI18n() + + // login process + const loginProcess = async (formData) => { + const param = { + langCd: currentLocale, + lastEditUser: formData.get('id'), + loginId: formData.get('id'), + pwd: formData.get('password'), + } + + await post({ url: '/api/login/v1.0/login', data: param }).then((res) => { + if (res) { + if (res.result.resultCode == 'S') { + // console.log('res.data', res.data) + // 비밀번호 초기화가 필요한 경우 + // if (res.data.pwdInitYn != 'Y') { + // alert('비밀번호 초기화가 필요한 경우') + // } else { + setSession(res.data) + redirect('/') + // } + } else { + alert(res.result.resultMsg) + } + } + }) + } + + // 비밀번호 초기화 관련 + const [open, setOpen] = useRecoilState(modalState) + const [contents, setContent] = useRecoilState(modalContent) + + const initPasswordProcess = async (formData) => { + const param = { + langCd: currentLocale, + lastEditUser: formData.get('checkId'), + loginId: formData.get('checkId'), + email: formData.get('checkEmail'), + } + + await patch({ url: '/api/login/v1.0/user/init-password', data: param }).then((res) => { + if (res) { + if (res.result.resultCode == 'S') { + alert(t('login.init_password.complete_message')) + redirect('/login') + } else { + alert(res.result.resultMsg) + } + } + }) + } + + const initPasswordContent = ( +
+
+

{t('login.init_password.title')}

+

{t('login.init_password.sub_title')}

+
+ +
+ +
+
+
+ +
+
+ +
+
+

+ +

+
+
+ ) + + return ( +
+
-
+

{t('site.name')}

+

{t('site.sub_name')}

+
+ +
+
Password -
-

- Not a member?{' '} - - Start a 14 day free trial - +

+

diff --git a/src/lib/authActions.js b/src/lib/authActions.js index 60fac21a..06c02ef0 100644 --- a/src/lib/authActions.js +++ b/src/lib/authActions.js @@ -27,6 +27,28 @@ export async function getSession() { return session } +export async function setSession(data) { + const session = await getSession() + + session.userId = data.userId + session.name = data.name + session.saleStoreId = data.saleStoreId + session.mail = data.mail + session.tel = data.tel + session.storeId = data.storeId + session.userNm = data.userNm + session.userNmKana = data.userNmKana + session.category = data.category + session.telNo = data.telNo + session.fax = data.fax + session.email = data.email + session.pwdInitYn = data.pwdInitYn + session.isLoggedIn = true + // console.log('session:', session) + + await session.save() +} + export async function login(formData) { const session = await getSession()