From e33a330786ffbfcd774de00dc697c6dff47faf27 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 20 Feb 2023 14:20:44 +0700
Subject: fix

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

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

diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx
new file mode 100644
index 00000000..e598fe48
--- /dev/null
+++ b/src/lib/auth/components/Login.jsx
@@ -0,0 +1,99 @@
+import Image from "next/image"
+import IndoteknikLogo from "@/images/logo.png"
+import Link from "@/core/components/elements/Link/Link"
+import { useState } from "react"
+import loginApi from "../api/loginApi"
+import { useRouter } from "next/router"
+import Alert from "@/core/components/elements/Alert/Alert"
+import { setAuth } from "@/core/utils/auth"
+
+const Login = () => {
+  const router = useRouter()
+  const [ email, setEmail ] = useState('')
+  const [ password, setPassword ] = useState('')
+  const [ isLoading, setIsLoading ] = useState(false)
+  const [ alert, setAlert ] = useState(null)
+
+  const handleSubmit = async (e) => {
+    e.preventDefault()
+    setIsLoading(true)
+    const login = await loginApi({ email, password })
+    setIsLoading(false)
+
+    if (login.isAuth) {
+      setAuth(login.user)
+      router.push('/')
+      return
+    }
+    switch (login.reason) {
+      case 'NOT_FOUND':
+        setAlert({
+          children: 'Email atau password tidak cocok',
+          type: 'info'
+        })
+        break
+      case 'NOT_ACTIVE':
+        setAlert({
+          children: (
+            <>
+              Email belum diaktivasi, 
+              <Link className="text-gray-900" href={`/activate?email=${email}`}>aktivasi sekarang</Link>
+            </>
+          ),
+          type: 'info'
+        })
+        break
+    }
+  }
+
+  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">Mulai Belanja Sekarang</h1>
+      <h2 className="text-gray_r-11 font-normal mt-1 mb-4">Masuk ke akun kamu untuk belanja</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="email">Alamat Email</label>
+          <input 
+            type="text" 
+            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 ? 'Masuk' : 'Loading...'}
+        </button>
+      </form>
+      <p className="text-gray_r-11 mt-4">Belum punya akun Indoteknik? <Link href="/register" className="inline">Daftar</Link></p>
+    </div>
+  )
+}
+
+export default Login
\ No newline at end of file
-- 
cgit v1.2.3


From 4fd738fd54f81fa53c2b3e78b7a80fbfda250352 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Feb 2023 10:19:32 +0700
Subject: fix

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

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

diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx
index e598fe48..acb6e8c3 100644
--- a/src/lib/auth/components/Login.jsx
+++ b/src/lib/auth/components/Login.jsx
@@ -64,7 +64,7 @@ const Login = () => {
         <div>
           <label htmlFor="email">Alamat Email</label>
           <input 
-            type="text" 
+            type="email" 
             id="email" 
             className="form-input w-full mt-3" 
             value={email}
-- 
cgit v1.2.3


From f66b12fd1d0b83af0d7230d7b1565fbe00afbe3c Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 11:03:34 +0700
Subject: prettier

---
 src/lib/auth/components/Login.jsx | 93 +++++++++++++++++++++------------------
 1 file changed, 50 insertions(+), 43 deletions(-)

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

diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx
index acb6e8c3..971188a2 100644
--- a/src/lib/auth/components/Login.jsx
+++ b/src/lib/auth/components/Login.jsx
@@ -1,18 +1,18 @@
-import Image from "next/image"
-import IndoteknikLogo from "@/images/logo.png"
-import Link from "@/core/components/elements/Link/Link"
-import { useState } from "react"
-import loginApi from "../api/loginApi"
-import { useRouter } from "next/router"
-import Alert from "@/core/components/elements/Alert/Alert"
-import { setAuth } from "@/core/utils/auth"
+import Image from 'next/image'
+import IndoteknikLogo from '@/images/logo.png'
+import Link from '@/core/components/elements/Link/Link'
+import { useState } from 'react'
+import loginApi from '../api/loginApi'
+import { useRouter } from 'next/router'
+import Alert from '@/core/components/elements/Alert/Alert'
+import { setAuth } from '@/core/utils/auth'
 
 const Login = () => {
   const router = useRouter()
-  const [ email, setEmail ] = useState('')
-  const [ password, setPassword ] = useState('')
-  const [ isLoading, setIsLoading ] = useState(false)
-  const [ alert, setAlert ] = useState(null)
+  const [email, setEmail] = useState('')
+  const [password, setPassword] = useState('')
+  const [isLoading, setIsLoading] = useState(false)
+  const [alert, setAlert] = useState(null)
 
   const handleSubmit = async (e) => {
     e.preventDefault()
@@ -36,8 +36,10 @@ const Login = () => {
         setAlert({
           children: (
             <>
-              Email belum diaktivasi, 
-              <Link className="text-gray-900" href={`/activate?email=${email}`}>aktivasi sekarang</Link>
+              Email belum diaktivasi,
+              <Link className='text-gray-900' href={`/activate?email=${email}`}>
+                aktivasi sekarang
+              </Link>
             </>
           ),
           type: 'info'
@@ -47,53 +49,58 @@ const Login = () => {
   }
 
   return (
-    <div className="p-6 pt-10 flex flex-col items-center">
-      <Link href="/">
-        <Image src={IndoteknikLogo} alt="Logo Indoteknik" width={150} height={50} />
+    <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">Mulai Belanja Sekarang</h1>
-      <h2 className="text-gray_r-11 font-normal mt-1 mb-4">Masuk ke akun kamu untuk belanja</h2>
-      
-      { alert && (
-        <Alert className="text-center" type={alert.type}>
-          { alert.children }
+      <h1 className='text-2xl mt-4 font-semibold'>Mulai Belanja Sekarang</h1>
+      <h2 className='text-gray_r-11 font-normal mt-1 mb-4'>Masuk ke akun kamu untuk belanja</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}>
+      <form className='w-full mt-6 flex flex-col gap-y-4' onSubmit={handleSubmit}>
         <div>
-          <label htmlFor="email">Alamat Email</label>
-          <input 
-            type="email" 
-            id="email" 
-            className="form-input w-full mt-3" 
+          <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"
+            placeholder='contoh@email.com'
           />
         </div>
         <div>
-          <label htmlFor="password">Kata Sandi</label>
-          <input 
-            type="password" 
-            id="password" 
-            className="form-input w-full mt-3" 
+          <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="••••••••••••"
+            placeholder='••••••••••••'
           />
         </div>
-        <button 
-          type="submit" 
-          className="btn-solid-red w-full mt-2"
+        <button
+          type='submit'
+          className='btn-solid-red w-full mt-2'
           disabled={!email || !password || isLoading}
         >
-          { !isLoading ? 'Masuk' : 'Loading...'}
+          {!isLoading ? 'Masuk' : 'Loading...'}
         </button>
       </form>
-      <p className="text-gray_r-11 mt-4">Belum punya akun Indoteknik? <Link href="/register" className="inline">Daftar</Link></p>
+      <p className='text-gray_r-11 mt-4'>
+        Belum punya akun Indoteknik?{' '}
+        <Link href='/register' className='inline'>
+          Daftar
+        </Link>
+      </p>
     </div>
   )
 }
 
-export default Login
\ No newline at end of file
+export default Login
-- 
cgit v1.2.3


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/Login.jsx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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

diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx
index 971188a2..92d38c11 100644
--- a/src/lib/auth/components/Login.jsx
+++ b/src/lib/auth/components/Login.jsx
@@ -93,12 +93,13 @@ const Login = () => {
           {!isLoading ? 'Masuk' : 'Loading...'}
         </button>
       </form>
-      <p className='text-gray_r-11 mt-4'>
+      
+      <div className='text-gray_r-11 mt-4'>
         Belum punya akun Indoteknik?{' '}
         <Link href='/register' className='inline'>
           Daftar
         </Link>
-      </p>
+      </div>
     </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/Login.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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

diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx
index 92d38c11..01b2a571 100644
--- a/src/lib/auth/components/Login.jsx
+++ b/src/lib/auth/components/Login.jsx
@@ -87,13 +87,13 @@ const Login = () => {
         </div>
         <button
           type='submit'
-          className='btn-solid-red w-full mt-2'
+          className='btn-yellow w-full mt-2'
           disabled={!email || !password || isLoading}
         >
           {!isLoading ? 'Masuk' : 'Loading...'}
         </button>
       </form>
-      
+
       <div className='text-gray_r-11 mt-4'>
         Belum punya akun Indoteknik?{' '}
         <Link href='/register' className='inline'>
-- 
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/Login.jsx | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

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

diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx
index 01b2a571..b4e94e0a 100644
--- a/src/lib/auth/components/Login.jsx
+++ b/src/lib/auth/components/Login.jsx
@@ -37,7 +37,10 @@ const Login = () => {
           children: (
             <>
               Email belum diaktivasi,
-              <Link className='text-gray-900' href={`/activate?email=${email}`}>
+              <Link
+                className='text-gray-900'
+                href={`/activate?email=${email}`}
+              >
                 aktivasi sekarang
               </Link>
             </>
@@ -51,18 +54,29 @@ const Login = () => {
   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'>Mulai Belanja Sekarang</h1>
       <h2 className='text-gray_r-11 font-normal mt-1 mb-4'>Masuk ke akun kamu untuk belanja</h2>
 
       {alert && (
-        <Alert className='text-center' type={alert.type}>
+        <Alert
+          className='text-center'
+          type={alert.type}
+        >
           {alert.children}
         </Alert>
       )}
 
-      <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='email'>Alamat Email</label>
           <input
@@ -96,7 +110,10 @@ const Login = () => {
 
       <div className='text-gray_r-11 mt-4'>
         Belum punya akun Indoteknik?{' '}
-        <Link href='/register' className='inline'>
+        <Link
+          href='/register'
+          className='inline'
+        >
           Daftar
         </Link>
       </div>
-- 
cgit v1.2.3


From 14ad96a9d010790fe7a482035d6d88f36db660fe Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 24 Feb 2023 10:07:12 +0700
Subject: fix

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

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

diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx
index b4e94e0a..b25cf4fe 100644
--- a/src/lib/auth/components/Login.jsx
+++ b/src/lib/auth/components/Login.jsx
@@ -16,6 +16,7 @@ const Login = () => {
 
   const handleSubmit = async (e) => {
     e.preventDefault()
+    setAlert(null)
     setIsLoading(true)
     const login = await loginApi({ email, password })
     setIsLoading(false)
-- 
cgit v1.2.3

