diff --git a/src/app/(auth)/register/page.tsx b/src/app/(auth)/register/page.tsx index 9f647c2..024aa38 100644 --- a/src/app/(auth)/register/page.tsx +++ b/src/app/(auth)/register/page.tsx @@ -1,60 +1,5 @@ -'use client'; +import RegisterForm from '../../../module/auth/register-form/register-form.component'; -import { useState } from 'react'; -import { - AccountCard, - AccountContent, - AccountWrap, -} from '@/shared/components/account/AccountElements'; -import { useMutation } from '@apollo/client'; -import { USER_REGISTER } from '@/graphql/auth'; -import { useTitle } from '@/hooks/useTitle'; -import RegisterForm from './_components/RegisterForm'; -import RegisterSuccess from './_components/RegisterSuccess'; -import AccountHeader from '../_components/AccountHeader'; -import AccountFooter from '../_components/AccountFooter'; - -const Register = () => { - const [register] = useMutation(USER_REGISTER); - const [error, setError] = useState(''); - const [isRegistered, setIsRegistered] = useState(false); - - useTitle('Register - BeeQuant'); - - const onSubmit = async (data: { - email: string; - password: string; - displayName: string; - ref: string; - }) => { - const result = await register({ - variables: { - input: data, - }, - }); - - if (result.data?.register.code === 200) { - setIsRegistered(true); - } - // for register failed - setError(`Register failed: ${result.data?.register.message}`); - }; - - if (isRegistered) { - return ; - } - - return ( - - - - - - - - - - ); -}; - -export default Register; +export default function Register() { + return ; +} diff --git a/src/app/(auth)/_components/AccountFooter.tsx b/src/module/auth/components/AccountFooter.tsx similarity index 100% rename from src/app/(auth)/_components/AccountFooter.tsx rename to src/module/auth/components/AccountFooter.tsx diff --git a/src/app/(auth)/_components/AccountHeader.tsx b/src/module/auth/components/AccountHeader.tsx similarity index 100% rename from src/app/(auth)/_components/AccountHeader.tsx rename to src/module/auth/components/AccountHeader.tsx diff --git a/src/module/auth/login-form/login-form.component.tsx b/src/module/auth/login-form/login-form.component.tsx index 813a4ce..7e7d504 100644 --- a/src/module/auth/login-form/login-form.component.tsx +++ b/src/module/auth/login-form/login-form.component.tsx @@ -2,51 +2,19 @@ import { AccountCard, AccountContent, - AccountHead, - AccountLogo, - AccountLogoAccent, - AccountOr, - AccountSocial, - AccountSocialButtonFacebook, - AccountSocialButtonGoogle, - AccountTitle, AccountWrap, } from '@/shared/components/account/AccountElements'; -import FacebookIcon from 'mdi-react/FacebookIcon'; -import GooglePlusIcon from 'mdi-react/GooglePlusIcon'; +import AccountHeader from '../components/AccountHeader'; +import AccountFooter from '../components/AccountFooter'; import FormLayout from './FormLayout'; export default function LoginForm() { return ( - - - Welcome to -
- - BeeQuant - AI - -
-

Trading smart, trading with BeeQuant AI

-
+ - -

Or Easily Using

-
- - {/* @ts-ignore - Ignoring because of complex union types incorrectly inferred */} - - - - - - - +
diff --git a/src/module/auth/register-form/FormLayout.tsx b/src/module/auth/register-form/FormLayout.tsx new file mode 100644 index 0000000..608bf9e --- /dev/null +++ b/src/module/auth/register-form/FormLayout.tsx @@ -0,0 +1,41 @@ +'use client'; + +import { useState } from 'react'; +import { useMutation } from '@apollo/client'; +import { USER_REGISTER } from '@/graphql/auth'; +import { useTitle } from '@/hooks/useTitle'; +import RegisterSuccess from 'module/auth/register-form/RegisterSuccess'; +import RegisterForm from './RegisterFormGroup'; + +export default function FormLayout() { + const [register] = useMutation(USER_REGISTER); + const [error, setError] = useState(''); + const [isRegistered, setIsRegistered] = useState(false); + + useTitle('Register - BeeQuant'); + + const onSubmit = async (data: { + email: string; + password: string; + displayName: string; + ref: string; + }) => { + const result = await register({ + variables: { + input: data, + }, + }); + + if (result.data?.register.code === 200) { + setIsRegistered(true); + } + // for register failed + setError(`Register failed: ${result.data?.register.message}`); + }; + + if (isRegistered) { + return ; + } + + return ; +} diff --git a/src/app/(auth)/register/_components/RegisterForm.test.tsx b/src/module/auth/register-form/RegisterFormGroup.test.tsx similarity index 99% rename from src/app/(auth)/register/_components/RegisterForm.test.tsx rename to src/module/auth/register-form/RegisterFormGroup.test.tsx index 526e7b6..91a1583 100644 --- a/src/app/(auth)/register/_components/RegisterForm.test.tsx +++ b/src/module/auth/register-form/RegisterFormGroup.test.tsx @@ -1,6 +1,6 @@ import { render, fireEvent, waitFor } from '@testing-library/react'; import { useUserContext } from '@/hooks/userHooks'; -import RegisterForm from './RegisterForm'; +import RegisterForm from './RegisterFormGroup'; const mockLocalStorage = (() => { let store: Record = {}; diff --git a/src/app/(auth)/register/_components/RegisterForm.tsx b/src/module/auth/register-form/RegisterFormGroup.tsx similarity index 99% rename from src/app/(auth)/register/_components/RegisterForm.tsx rename to src/module/auth/register-form/RegisterFormGroup.tsx index ae2647a..4867bd6 100644 --- a/src/app/(auth)/register/_components/RegisterForm.tsx +++ b/src/module/auth/register-form/RegisterFormGroup.tsx @@ -1,3 +1,5 @@ +'use client'; + import { useState } from 'react'; import AccountOutlineIcon from 'mdi-react/AccountOutlineIcon'; import { Alert } from 'react-bootstrap'; diff --git a/src/app/(auth)/register/_components/RegisterSuccess.test.tsx b/src/module/auth/register-form/RegisterSuccess.test.tsx similarity index 100% rename from src/app/(auth)/register/_components/RegisterSuccess.test.tsx rename to src/module/auth/register-form/RegisterSuccess.test.tsx diff --git a/src/app/(auth)/register/_components/RegisterSuccess.tsx b/src/module/auth/register-form/RegisterSuccess.tsx similarity index 100% rename from src/app/(auth)/register/_components/RegisterSuccess.tsx rename to src/module/auth/register-form/RegisterSuccess.tsx diff --git a/src/module/auth/register-form/register-form.component.tsx b/src/module/auth/register-form/register-form.component.tsx new file mode 100644 index 0000000..9fc23eb --- /dev/null +++ b/src/module/auth/register-form/register-form.component.tsx @@ -0,0 +1,24 @@ +'use client'; + +import { + AccountCard, + AccountContent, + AccountWrap, +} from '@/shared/components/account/AccountElements'; +import AccountHeader from '../components/AccountHeader'; +import AccountFooter from '../components/AccountFooter'; +import FormLayout from './FormLayout'; + +export default function RegisterForm() { + return ( + + + + + + + + + + ); +}