diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-20 14:33:21 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-20 14:33:21 +0700 |
| commit | 833488811b4164d7fbdce9bd70e171f06d62bf8d (patch) | |
| tree | c781a3ced1f27b8f1c81ed5401fd758d79c1de1c /src/lib/auth/components/Register.jsx | |
| parent | 87e7292941a251f09b5af39d9020896a3bfb0f97 (diff) | |
login and register
Diffstat (limited to 'src/lib/auth/components/Register.jsx')
| -rw-r--r-- | src/lib/auth/components/Register.jsx | 150 |
1 files changed, 6 insertions, 144 deletions
diff --git a/src/lib/auth/components/Register.jsx b/src/lib/auth/components/Register.jsx index 4ea62899..6c0152dc 100644 --- a/src/lib/auth/components/Register.jsx +++ b/src/lib/auth/components/Register.jsx @@ -1,150 +1,12 @@ -import Image from 'next/image' -import Link from '@/core/components/elements/Link/Link' -import IndoteknikLogo from '@/images/logo.png' -import { useState } from 'react' -import registerApi from '../api/registerApi' -import Alert from '@/core/components/elements/Alert/Alert' -import axios from 'axios' +import RegisterDesktop from './RegisterDesktop' +import RegisterMobile from './RegisterMobile' const Register = () => { - const [fullname, setFullname] = useState('') - const [email, setEmail] = useState('') - const [password, setPassword] = useState('') - const [companyName, setCompanyName] = useState('') - const [isLoading, setIsLoading] = useState('') - const [alert, setAlert] = useState(null) - - const handleSubmit = async (e) => { - e.preventDefault() - setAlert(null) - setIsLoading(true) - const data = { - name: fullname, - company: companyName, - email, - password - } - const isRegistered = await registerApi({ data }) - setIsLoading(false) - if (isRegistered.register) { - await axios.post(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/activation-request`, { email }) - setAlert({ - children: 'Berhasil mendaftarkan akun anda, cek email untuk melakukan aktivasi akun', - type: 'success' - }) - setCompanyName('') - setFullname('') - setEmail('') - setPassword('') - } else { - switch (isRegistered.reason) { - case 'EMAIL_USED': - setAlert({ - children: 'Email telah digunakan', - type: 'info' - }) - break - } - } - } - return ( - <div className='p-6 pt-10 flex flex-col items-center min-h-screen'> - <Link href='/'> - <Image - src={IndoteknikLogo} - alt='Logo Indoteknik' - width={150} - height={50} - /> - </Link> - - <h1 className='text-2xl mt-4 font-semibold'>Daftar Akun Indoteknik</h1> - <h2 className='text-gray_r-11 font-normal mt-1 mb-4 text-center'> - Buat akun sekarang lebih mudah dan terverifikasi - </h2> - - {alert && ( - <Alert - className='text-center' - type={alert.type} - > - {alert.children} - </Alert> - )} - - <form - className='w-full mt-6 flex flex-col gap-y-4' - onSubmit={handleSubmit} - > - <div> - <label htmlFor='companyName'> - Nama Perusahaan <span className='text-gray_r-11'>(opsional)</span> - </label> - <input - type='text' - id='companyName' - className='form-input w-full mt-3' - value={companyName} - onChange={(e) => setCompanyName(e.target.value.toUpperCase())} - placeholder='cth: INDOTEKNIK DOTCOM GEMILANG' - autoCapitalize='true' - /> - </div> - - <div> - <label htmlFor='fullname'>Nama Lengkap</label> - <input - type='text' - id='fullname' - className='form-input w-full mt-3' - value={fullname} - onChange={(e) => setFullname(e.target.value)} - placeholder='John Doe' - /> - </div> - <div> - <label htmlFor='email'>Alamat Email</label> - <input - type='email' - id='email' - className='form-input w-full mt-3' - value={email} - onChange={(e) => setEmail(e.target.value)} - placeholder='contoh@email.com' - /> - </div> - <div> - <label htmlFor='password'>Kata Sandi</label> - <input - type='password' - id='password' - className='form-input w-full mt-3' - value={password} - onChange={(e) => setPassword(e.target.value)} - placeholder='••••••••••••' - /> - </div> - - <button - type='submit' - className='btn-yellow w-full mt-2' - disabled={!email || !password || !fullname || isLoading} - > - {!isLoading ? 'Daftar' : 'Loading...'} - </button> - </form> - - <div className='text-gray_r-11 mt-4'> - Sudah punya akun Indoteknik?{' '} - <Link - href='/login' - className='inline' - > - Masuk - </Link> - </div> - </div> + <> + <RegisterMobile /> + <RegisterDesktop /> + </> ) } |
