From 4e5257d73f18fd76c66cc61f1f09034d12bc02b8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 21 Dec 2022 17:11:01 +0700 Subject: menu profil saya --- next.config.js | 2 +- src/components/Header.js | 4 +- src/pages/login.js | 2 +- src/pages/my/profile.js | 95 ++++++++++++++++++++++++++++++++++++++++ src/pages/shop/product/[slug].js | 2 +- src/styles/globals.css | 8 ++-- 6 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 src/pages/my/profile.js 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 }) {
{auth && ( - + Profil Saya
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.component} ) : ''}
- + { + 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 ( + <> +
+ + +

Profil Saya

+ + + + + + + + + + + + + + + + +
+ + ); +} \ 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 }) {
- +