diff options
Diffstat (limited to 'src/lib/auth')
| -rw-r--r-- | src/lib/auth/api/registerApi.js | 8 | ||||
| -rw-r--r-- | src/lib/auth/components/Register.jsx | 17 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/lib/auth/api/registerApi.js b/src/lib/auth/api/registerApi.js new file mode 100644 index 00000000..f3d75ce8 --- /dev/null +++ b/src/lib/auth/api/registerApi.js @@ -0,0 +1,8 @@ +import odooApi from '@/core/api/odooApi' + +const registerApi = async ({ data }) => { + const dataRegister = await odooApi('POST', '/api/v1/user/register', data) + return dataRegister +} + +export default registerApi 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> |
