summaryrefslogtreecommitdiff
path: root/src/lib/auth
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/auth')
-rw-r--r--src/lib/auth/api/loginApi.js12
-rw-r--r--src/lib/auth/components/Login.jsx93
2 files changed, 54 insertions, 51 deletions
diff --git a/src/lib/auth/api/loginApi.js b/src/lib/auth/api/loginApi.js
index 4782680c..e393309c 100644
--- a/src/lib/auth/api/loginApi.js
+++ b/src/lib/auth/api/loginApi.js
@@ -1,12 +1,8 @@
-import odooApi from "@/core/api/odooApi"
+import odooApi from '@/core/api/odooApi'
-const loginApi = async ({email, password}) => {
- let result = await odooApi(
- 'POST',
- '/api/v1/user/login',
- {email, password}
- )
+const loginApi = async ({ email, password }) => {
+ let result = await odooApi('POST', '/api/v1/user/login', { email, password })
return result
}
-export default loginApi \ No newline at end of file
+export default loginApi
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