summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <rafizadanly@gmail.com>2022-12-21 17:11:01 +0700
committerRafi Zadanly <rafizadanly@gmail.com>2022-12-21 17:11:01 +0700
commit4e5257d73f18fd76c66cc61f1f09034d12bc02b8 (patch)
tree97178e8e88de99fe89ad6bd437da3a96acaf6f8a
parentcbc5837e578ca107f129f8b922efde3fe685c102 (diff)
menu profil saya
-rw-r--r--next.config.js2
-rw-r--r--src/components/Header.js4
-rw-r--r--src/pages/login.js2
-rw-r--r--src/pages/my/profile.js95
-rw-r--r--src/pages/shop/product/[slug].js2
-rw-r--r--src/styles/globals.css8
6 files changed, 105 insertions, 8 deletions
diff --git a/next.config.js b/next.config.js
index 1897a178..a7188872 100644
--- a/next.config.js
+++ b/next.config.js
@@ -13,7 +13,7 @@ const nextConfig = {
},
env: {
SELF_HOST: 'http://localhost:3000',
- ODOO_HOST: 'https://erp.indoteknik.com',
+ ODOO_HOST: 'http://35.219.111.47:8069',
SOLR_HOST: 'http://34.101.189.218:8983',
MAIL_PORT: 465,
MAIL_HOST: 'smtp.gmail.com',
diff --git a/src/components/Header.js b/src/components/Header.js
index ca59701e..a294c140 100644
--- a/src/components/Header.js
+++ b/src/components/Header.js
@@ -27,7 +27,7 @@ export default function Header({ title }) {
const [auth, setAuth] = useState();
useEffect(() => {
- if (!auth) setAuth(getAuth())
+ if (!auth) setAuth(getAuth());
}, [auth]);
useEffect(() => {
@@ -87,7 +87,7 @@ export default function Header({ title }) {
</div>
<div className="flex flex-col">
{auth && (
- <Link className="flex w-full font-normal text-gray_r-11 border-b border-gray_r-6 p-4 py-3" href="/shop/brands" onClick={closeMenu}>
+ <Link className="flex w-full font-normal text-gray_r-11 border-b border-gray_r-6 p-4 py-3" href="/my/profile" onClick={closeMenu}>
<span>Profil Saya</span>
<div className="ml-auto">
<ChevronRightIcon className="text-gray_r-12 w-5" />
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 ? (
diff --git a/src/styles/globals.css b/src/styles/globals.css
index fa117ac1..813b78d0 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -110,6 +110,7 @@ html, body {
leading-none
focus:outline-none
focus:border-yellow_r-9
+ disabled:bg-gray_r-5
;
}
@@ -119,7 +120,8 @@ html, body {
@apply
block
w-fit
- p-3
+ py-3
+ px-6
rounded
border
text-center
@@ -273,8 +275,8 @@ html, body {
top-0
border-b
border-gray_r-7
- shadow-2xl
- shadow-gray_r-1
+ shadow-lg
+ shadow-gray_r-2
z-50
;
}