diff options
| author | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-30 09:56:08 +0700 |
|---|---|---|
| committer | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-30 09:56:08 +0700 |
| commit | ff830e7c6d6fbd768a91ed8f0e7be460656a6d29 (patch) | |
| tree | 86a4797323f080a459591d45b9d5a34ee869ab65 /src/pages/my/address | |
| parent | ba6eca41f673f8db4d9f686fb7dab2358a4dc5eb (diff) | |
Address page
Diffstat (limited to 'src/pages/my/address')
| -rw-r--r-- | src/pages/my/address/create.js | 58 | ||||
| -rw-r--r-- | src/pages/my/address/index.js | 45 |
2 files changed, 103 insertions, 0 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 |
