diff options
| author | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-21 17:11:01 +0700 |
|---|---|---|
| committer | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-21 17:11:01 +0700 |
| commit | 4e5257d73f18fd76c66cc61f1f09034d12bc02b8 (patch) | |
| tree | 97178e8e88de99fe89ad6bd437da3a96acaf6f8a /src/pages | |
| parent | cbc5837e578ca107f129f8b922efde3fe685c102 (diff) | |
menu profil saya
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/login.js | 2 | ||||
| -rw-r--r-- | src/pages/my/profile.js | 95 | ||||
| -rw-r--r-- | src/pages/shop/product/[slug].js | 2 |
3 files changed, 97 insertions, 2 deletions
diff --git a/src/pages/login.js b/src/pages/login.js index a559c613..0dfacfaa 100644 --- a/src/pages/login.js +++ b/src/pages/login.js @@ -63,7 +63,7 @@ export default function Login() { <Alert className="text-center" type={alert.type}>{alert.component}</Alert> ) : ''} <form onSubmit={login} className="w-full"> - <label className="form-label mt-4 mb-2">Nama Lengkap</label> + <label className="form-label mt-4 mb-2">Alamat Email</label> <input type="text" className="form-input bg-gray_r-2" diff --git a/src/pages/my/profile.js b/src/pages/my/profile.js new file mode 100644 index 00000000..a0aeb938 --- /dev/null +++ b/src/pages/my/profile.js @@ -0,0 +1,95 @@ +import { useEffect, useState } from "react"; +import { toast } from "react-hot-toast"; +import Header from "../../components/Header"; +import Layout from "../../components/Layout"; +import apiOdoo from "../../helpers/apiOdoo"; +import { + getAuth, + setAuth as setAuthCookie +} from "../../helpers/auth"; + +export default function MyProfile() { + const [auth, setAuth] = useState({ + name: '', + email: '', + phone: '', + mobile: '' + }); + + useEffect(() => { + setAuth(getAuth()); + }, []); + + const update = async (e) => { + e.preventDefault(); + let update = await apiOdoo('PUT', `/api/v1/user/${auth.id}`, { + name: auth.name, + phone: auth.phone, + mobile: auth.mobile, + token: auth.token + }); + setAuthCookie(update.user); + toast.success('Berhasil mengubah profil', { duration: 1500 }); + }; + + const handleInput = (e) => { + let authToUpdate = auth; + authToUpdate[e.target.name] = e.target.value; + setAuth({ ...authToUpdate }); + } + + return ( + <> + <Header title="Profil Saya - Indoteknik" /> + <Layout> + <form onSubmit={update} className="w-full p-4"> + <h1 className="mb-6">Profil Saya</h1> + + <label className="form-label mt-4 mb-2">Email</label> + <input + type="text" + className="form-input bg-gray_r-2" + placeholder="johndoe@gmail.com" + name="email" + value={auth.email} + onChange={handleInput} + disabled={true} + /> + + <label className="form-label mt-4 mb-2">Nama Lengkap</label> + <input + type="text" + className="form-input bg-gray_r-2" + placeholder="John Doe" + name="name" + value={auth.name} + onChange={handleInput} + /> + + <label className="form-label mt-4 mb-2">No Telepon</label> + <input + type="tel" + className="form-input bg-gray_r-2" + placeholder="08xxxxxxxx" + name="phone" + value={auth.phone} + onChange={handleInput} + /> + + <label className="form-label mt-4 mb-2">No Handphone</label> + <input + type="tel" + className="form-input bg-gray_r-2" + placeholder="08xxxxxxxx" + name="mobile" + value={auth.mobile} + onChange={handleInput} + /> + + <button type="submit" className="btn-yellow float-right mt-4">Simpan</button> + + </form> + </Layout> + </> + ); +}
\ No newline at end of file diff --git a/src/pages/shop/product/[slug].js b/src/pages/shop/product/[slug].js index 7ce55562..5913f17d 100644 --- a/src/pages/shop/product/[slug].js +++ b/src/pages/shop/product/[slug].js @@ -138,7 +138,7 @@ export default function ProductDetail({ product }) { <div className="flex gap-x-2 mt-5"> <div className="w-9/12"> - <label className="form-label mb-1">Pilih: <span className="text-gray-800">{product.variant_total} Varian</span></label> + <label className="form-label mb-1">Pilih: <span className="text-gray_r-11 font-normal">{product.variant_total} Varian</span></label> <select name="variant" className="form-input" value={selectedVariant} onChange={onchangeVariant} > <option value="" disabled={selectedVariant != "" ? true : false}>Pilih Varian...</option> {product.variants.length > 1 ? ( |
