From ebda24f072741d11da7dd5e406eb5bce069dbf6a Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 15:45:05 +0700
Subject: fix

---
 src/lib/auth/components/Register.jsx | 95 ++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 src/lib/auth/components/Register.jsx

(limited to 'src/lib/auth/components/Register.jsx')

diff --git a/src/lib/auth/components/Register.jsx b/src/lib/auth/components/Register.jsx
new file mode 100644
index 00000000..4b8a8053
--- /dev/null
+++ b/src/lib/auth/components/Register.jsx
@@ -0,0 +1,95 @@
+import Image from 'next/image'
+import Link from '@/core/components/elements/Link/Link'
+import IndoteknikLogo from '@/images/logo.png'
+import { useState } from 'react'
+
+const Register = () => {
+  const [fullname, setFullname] = useState('')
+  const [email, setEmail] = useState('')
+  const [password, setPassword] = useState('')
+  const [companyName, setCompanyName] = useState('')
+  const [isLoading, setIsLoading] = useState('')
+
+  const handleSubmit = (e) => {
+    e.preventDefault()
+  }
+
+  return (
+    <div className='p-6 pt-10 flex flex-col items-center'>
+      <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>
+
+      <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
+          />
+        </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-solid-red w-full mt-2'
+          disabled={!email || !password || 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>
+  )
+}
+
+export default Register
-- 
cgit v1.2.3


From 4360ec478bee28c1edae5e614065c31cb9da64c1 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 15:46:23 +0700
Subject: fix

---
 src/lib/auth/components/Register.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/auth/components/Register.jsx')

diff --git a/src/lib/auth/components/Register.jsx b/src/lib/auth/components/Register.jsx
index 4b8a8053..1f7a55d5 100644
--- a/src/lib/auth/components/Register.jsx
+++ b/src/lib/auth/components/Register.jsx
@@ -35,7 +35,7 @@ const Register = () => {
             value={companyName}
             onChange={(e) => setCompanyName(e.target.value.toUpperCase())}
             placeholder='cth: INDOTEKNIK DOTCOM GEMILANG'
-            autoCapitalize
+            autoCapitalize='true'
           />
         </div>
 
-- 
cgit v1.2.3


From 71a4dd291e9fc1d1bb72b57a22f21d1c03b92d8f Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 15:48:38 +0700
Subject: fix

---
 src/lib/auth/components/Register.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/auth/components/Register.jsx')

diff --git a/src/lib/auth/components/Register.jsx b/src/lib/auth/components/Register.jsx
index 1f7a55d5..e3e3c4fa 100644
--- a/src/lib/auth/components/Register.jsx
+++ b/src/lib/auth/components/Register.jsx
@@ -75,7 +75,7 @@ const Register = () => {
 
         <button
           type='submit'
-          className='btn-solid-red w-full mt-2'
+          className='btn-yellow w-full mt-2'
           disabled={!email || !password || isLoading}
         >
           {!isLoading ? 'Daftar' : 'Loading...'}
-- 
cgit v1.2.3


From c6a489da2f3df46b867891c12a3c5f4121f920b0 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 17:11:09 +0700
Subject: fix

---
 src/lib/auth/components/Register.jsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'src/lib/auth/components/Register.jsx')

diff --git a/src/lib/auth/components/Register.jsx b/src/lib/auth/components/Register.jsx
index e3e3c4fa..df08541d 100644
--- a/src/lib/auth/components/Register.jsx
+++ b/src/lib/auth/components/Register.jsx
@@ -2,6 +2,7 @@ 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'
 
 const Register = () => {
   const [fullname, setFullname] = useState('')
@@ -10,8 +11,16 @@ const Register = () => {
   const [companyName, setCompanyName] = useState('')
   const [isLoading, setIsLoading] = useState('')
 
-  const handleSubmit = (e) => {
+  const handleSubmit = async (e) => {
     e.preventDefault()
+    const data = {
+      name: fullname,
+      company: companyName,
+      email,
+      password
+    }
+    const isRegistered = await registerApi({ data })
+    console.log(isRegistered)
   }
 
   return (
@@ -27,7 +36,9 @@ const Register = () => {
 
       <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>
+          <label htmlFor='companyName'>
+            Nama Perusahaan <span className='text-gray_r-11'>(opsional)</span>
+          </label>
           <input
             type='text'
             id='companyName'
@@ -76,7 +87,7 @@ const Register = () => {
         <button
           type='submit'
           className='btn-yellow w-full mt-2'
-          disabled={!email || !password || isLoading}
+          disabled={!email || !password || !fullname || isLoading}
         >
           {!isLoading ? 'Daftar' : 'Loading...'}
         </button>
-- 
cgit v1.2.3


From ac3fdf7be9982e65d8f83a20bc487f8dd62e3bfc Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 23:36:47 +0700
Subject: fix

---
 src/lib/auth/components/Register.jsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'src/lib/auth/components/Register.jsx')

diff --git a/src/lib/auth/components/Register.jsx b/src/lib/auth/components/Register.jsx
index df08541d..135972d3 100644
--- a/src/lib/auth/components/Register.jsx
+++ b/src/lib/auth/components/Register.jsx
@@ -26,7 +26,12 @@ const Register = () => {
   return (
     <div className='p-6 pt-10 flex flex-col items-center'>
       <Link href='/'>
-        <Image src={IndoteknikLogo} alt='Logo Indoteknik' width={150} height={50} />
+        <Image
+          src={IndoteknikLogo}
+          alt='Logo Indoteknik'
+          width={150}
+          height={50}
+        />
       </Link>
 
       <h1 className='text-2xl mt-4 font-semibold'>Daftar Akun Indoteknik</h1>
@@ -34,7 +39,10 @@ const Register = () => {
         Buat akun sekarang lebih mudah dan terverifikasi
       </h2>
 
-      <form className='w-full mt-6 flex flex-col gap-y-4' onSubmit={handleSubmit}>
+      <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>
@@ -95,7 +103,10 @@ const Register = () => {
 
       <div className='text-gray_r-11 mt-4'>
         Sudah punya akun Indoteknik?{' '}
-        <Link href='/login' className='inline'>
+        <Link
+          href='/login'
+          className='inline'
+        >
           Masuk
         </Link>
       </div>
-- 
cgit v1.2.3


From 0de0fda98dc35bd6503f1a45a52878b154a94c75 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Thu, 23 Feb 2023 10:52:40 +0700
Subject: fox

---
 src/lib/auth/components/Register.jsx | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

(limited to 'src/lib/auth/components/Register.jsx')

diff --git a/src/lib/auth/components/Register.jsx b/src/lib/auth/components/Register.jsx
index 135972d3..d02081ce 100644
--- a/src/lib/auth/components/Register.jsx
+++ b/src/lib/auth/components/Register.jsx
@@ -3,6 +3,8 @@ 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'
 
 const Register = () => {
   const [fullname, setFullname] = useState('')
@@ -10,9 +12,12 @@ const Register = () => {
   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,
@@ -20,7 +25,27 @@ const Register = () => {
       password
     }
     const isRegistered = await registerApi({ data })
-    console.log(isRegistered)
+    setIsLoading(false)
+    if (isRegistered.register) {
+      await axios.post(`${process.env.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 (
@@ -39,6 +64,15 @@ const Register = () => {
         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}
-- 
cgit v1.2.3

