From d19b40f2972cc74105cfb8390a3b0fe3a4695b3a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 17 Nov 2022 17:30:03 +0700 Subject: Login process to Odoo Api --- src/components/Header.js | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src/components/Header.js') diff --git a/src/components/Header.js b/src/components/Header.js index fb0e56a1..3e9d7ea0 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -8,6 +8,7 @@ import { useEffect, useRef, useState } from "react"; import Head from "next/head"; import Logo from "../images/logo.png"; import { useRouter } from "next/router"; +import { getAuth } from "../helpers/auth"; export default function Header({ title }) { @@ -16,6 +17,11 @@ export default function Header({ title }) { const [searchQuery, setSearchQuery] = useState(q); const searchQueryRef = useRef(); const [isMenuActive, setIsMenuActive] = useState(false); + const [auth, setAuth] = useState(); + + useEffect(() => { + if (!auth) setAuth(getAuth()) + }, [auth]); useEffect(() => { if (q) searchQueryRef.current.blur(); @@ -35,25 +41,39 @@ export default function Header({ title }) { {title} -
-
- Masuk - Daftar +
+
+ {auth ? ( +

Hi, {auth.name}

+ ) : ( + <> + Masuk + Daftar + + )}
-
- - Brand +
+ {auth ? ( + + Profil Saya +
+ +
+ + ) : ''} + + Semua Brand
- - Blog + + Blog Indoteknik
-