summaryrefslogtreecommitdiff
path: root/src/pages/my
diff options
context:
space:
mode:
authorRafi Zadanly <rafizadanly@gmail.com>2022-12-30 09:56:08 +0700
committerRafi Zadanly <rafizadanly@gmail.com>2022-12-30 09:56:08 +0700
commitff830e7c6d6fbd768a91ed8f0e7be460656a6d29 (patch)
tree86a4797323f080a459591d45b9d5a34ee869ab65 /src/pages/my
parentba6eca41f673f8db4d9f686fb7dab2358a4dc5eb (diff)
Address page
Diffstat (limited to 'src/pages/my')
-rw-r--r--src/pages/my/address/create.js58
-rw-r--r--src/pages/my/address/index.js45
-rw-r--r--src/pages/my/menu.js6
-rw-r--r--src/pages/my/profile.js10
4 files changed, 111 insertions, 8 deletions
diff --git a/src/pages/my/address/create.js b/src/pages/my/address/create.js
new file mode 100644
index 00000000..3f8de7b5
--- /dev/null
+++ b/src/pages/my/address/create.js
@@ -0,0 +1,58 @@
+import AppBar from "../../../components/AppBar";
+import Layout from "../../../components/Layout";
+import WithAuth from "../../../components/WithAuth";
+
+export default function CreateAddress() {
+ return (
+ <WithAuth>
+ <Layout>
+ <AppBar title="Tambah Alamat" />
+
+ <form className="px-4">
+ <label className="form-label mt-4 mb-2">Nama Kontak</label>
+ <input
+ type="text"
+ className="form-input bg-gray_r-2"
+ placeholder="John Doe"
+ name="name"
+ />
+ <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"
+ />
+ <label className="form-label mt-4 mb-2">Alamat</label>
+ <input
+ type="tel"
+ className="form-input bg-gray_r-2"
+ placeholder="Jl. Bandengan Utara"
+ name="street"
+ />
+ <label className="form-label mt-4 mb-2">Kota atau Kecamatan</label>
+ <input
+ type="tel"
+ className="form-input bg-gray_r-2"
+ placeholder="Kel. Penjaringan Kec. Penjaringan Kota Jakarta Utara"
+ name="street2"
+ />
+ <label className="form-label mt-4 mb-2">Kode Pos</label>
+ <input
+ type="tel"
+ className="form-input bg-gray_r-2"
+ placeholder="10100"
+ name="street2"
+ />
+
+ <button
+ type="button"
+ className="btn-yellow float-right mt-6 w-full"
+ >
+ Simpan
+ </button>
+ </form>
+ </Layout>
+ </WithAuth>
+ );
+} \ No newline at end of file
diff --git a/src/pages/my/address/index.js b/src/pages/my/address/index.js
new file mode 100644
index 00000000..cac6e8f6
--- /dev/null
+++ b/src/pages/my/address/index.js
@@ -0,0 +1,45 @@
+import { useEffect, useState } from "react";
+import AppBar from "../../../components/AppBar";
+import Layout from "../../../components/Layout";
+import Link from "../../../components/Link";
+import WithAuth from "../../../components/WithAuth";
+import apiOdoo from "../../../helpers/apiOdoo";
+import { useAuth } from "../../../helpers/auth";
+
+export default function Address() {
+ const [auth] = useAuth();
+ const [addresses, setAddresses] = useState(null);
+
+ useEffect(() => {
+ const getAddress = async () => {
+ if (auth) {
+ const dataAddress = await apiOdoo('GET', `/api/v1/user/${auth.id}/address`);
+ setAddresses(dataAddress);
+ }
+ };
+ getAddress();
+ }, [auth]);
+
+ return (
+ <WithAuth>
+ <Layout>
+ <AppBar title="Daftar Alamat" />
+
+ <div className="text-right mt-4 px-4">
+ <Link href="/my/address/create">Tambah Alamat</Link>
+ </div>
+
+ <div className="grid gap-y-4 p-4">
+ { addresses && addresses.map((address, index) => (
+ <div className="p-4 rounded-md border border-gray_r-7" key={index}>
+ <p className="font-medium">{ address.name }</p>
+ <p className="mt-3 text-gray_r-11">{ address.mobile }</p>
+ <p className="mt-1 text-gray_r-11 leading-6">{ address.street } { address.street2 }</p>
+ <button className="btn-light mt-3 w-full">Ubah Alamat</button>
+ </div>
+ )) }
+ </div>
+ </Layout>
+ </WithAuth>
+ )
+} \ No newline at end of file
diff --git a/src/pages/my/menu.js b/src/pages/my/menu.js
index 84de3892..e21b0433 100644
--- a/src/pages/my/menu.js
+++ b/src/pages/my/menu.js
@@ -34,12 +34,12 @@ const serviceMenus = [
];
const settingMenus = [
- { icon: (<MapIcon className="w-5" />),name: 'Daftar Alamat', url: '/my/profile' },
+ { icon: (<MapIcon className="w-5" />),name: 'Daftar Alamat', url: '/my/address' },
{ icon: (<ArrowRightOnRectangleIcon className="w-5" />),name: 'Keluar Akun', url: '/logout' },
];
export default function MyMenu() {
- const [auth, setAuth] = useAuth();
+ const [auth] = useAuth();
return (
<>
@@ -52,7 +52,7 @@ export default function MyMenu() {
<UserIcon className="w-6" />
</div>
<div>
- <h2>{ auth.name }</h2>
+ <h2>{ auth?.name }</h2>
<div className="badge-red font-normal text-xs">Akun Bisnis</div>
</div>
</div>
diff --git a/src/pages/my/profile.js b/src/pages/my/profile.js
index be1a67b0..6e40230d 100644
--- a/src/pages/my/profile.js
+++ b/src/pages/my/profile.js
@@ -47,7 +47,7 @@ export default function MyProfile() {
<AppBar title="Akun Saya" />
<form onSubmit={update} className="w-full px-4">
- { auth?.id && (
+ { auth && (
<>
<label className="form-label mt-4 mb-2">Email</label>
<input
@@ -106,22 +106,22 @@ export default function MyProfile() {
) }
{ editMode && (
- <div className="flex justify-end gap-x-3">
+ <div className="flex gap-x-3">
<button
type="button"
- className="btn-light float-right mt-4"
+ className="btn-light flex-1 float-right mt-4"
onClick={cancelEdit}
>
Batal
</button>
- <button type="submit" className="btn-yellow float-right mt-4">Simpan</button>
+ <button type="submit" className="btn-yellow flex-1 float-right mt-4">Simpan</button>
</div>
) }
{ !editMode && (
<button
type="button"
- className="btn-light float-right mt-4"
+ className="btn-light float-right mt-4 w-full"
onClick={() => setEditMode(true)}
>
Ubah Profil