From 31d6352ab8855754ef18c01763d3c1b5a68de857 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 22 Dec 2022 15:29:18 +0700 Subject: Appbar component and auth hook (useAuth) --- src/pages/my/menu.js | 51 ++++++++++++++++++++++++ src/pages/my/profile.js | 104 +++++++++++++++++++++++------------------------- 2 files changed, 100 insertions(+), 55 deletions(-) create mode 100644 src/pages/my/menu.js (limited to 'src/pages/my') diff --git a/src/pages/my/menu.js b/src/pages/my/menu.js new file mode 100644 index 00000000..7454d8d1 --- /dev/null +++ b/src/pages/my/menu.js @@ -0,0 +1,51 @@ + +import AppBar from "../../components/AppBar"; +import Layout from "../../components/Layout"; +import Link from "../../components/Link"; +import { useAuth } from "../../helpers/auth"; +import { + ChevronRightIcon, + Cog6ToothIcon, + DocumentTextIcon, + UserCircleIcon, UserIcon +} from "@heroicons/react/24/outline"; + +const menus = [ + { name: 'Riwayat Pesanan', url: '/my/profile' }, + { name: 'Faktur Penjualan', url: '/my/profile' }, + { name: 'Faktur Pajak', url: '/my/profile' }, + { name: 'Surat Jalan', url: '/my/profile' } +]; + +export default function MyMenu() { + const [auth, setAuth] = useAuth(); + + return ( + <> + + + +
+
+ +
+

{ auth.name }

+

{ auth.email }

+
+
+ + + +
+ +
+ { menus.map((menu, index) => ( + + { menu.name } + + )) } +
+
+ + ); +} \ No newline at end of file diff --git a/src/pages/my/profile.js b/src/pages/my/profile.js index a0aeb938..44ccfebd 100644 --- a/src/pages/my/profile.js +++ b/src/pages/my/profile.js @@ -1,24 +1,17 @@ import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; +import AppBar from "../../components/AppBar"; import Header from "../../components/Header"; import Layout from "../../components/Layout"; +import WithAuth from "../../components/WithAuth"; import apiOdoo from "../../helpers/apiOdoo"; import { - getAuth, + useAuth, setAuth as setAuthCookie } from "../../helpers/auth"; export default function MyProfile() { - const [auth, setAuth] = useState({ - name: '', - email: '', - phone: '', - mobile: '' - }); - - useEffect(() => { - setAuth(getAuth()); - }, []); + const [auth, setAuth] = useAuth(); const update = async (e) => { e.preventDefault(); @@ -39,57 +32,58 @@ export default function MyProfile() { } return ( - <> -
+ -
-

Profil Saya

- - - + + + { auth && ( + <> + + - - + + - - + + - - + + + + ) } -
- +
); } \ No newline at end of file -- cgit v1.2.3