summaryrefslogtreecommitdiff
path: root/src/pages/my/address/index.js
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/address/index.js
parentba6eca41f673f8db4d9f686fb7dab2358a4dc5eb (diff)
Address page
Diffstat (limited to 'src/pages/my/address/index.js')
-rw-r--r--src/pages/my/address/index.js45
1 files changed, 45 insertions, 0 deletions
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