From e638d5fd0c55196a58cb75403e97c53a1c8a21c5 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Jan 2024 17:29:15 +0800 Subject: [PATCH] update header --- src/layout/MainLayout/Header/index.js | 101 ++++++++++++++------------ src/utils/Utils.js | 5 ++ 2 files changed, 61 insertions(+), 45 deletions(-) diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index 10c8499..fa31438 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -41,7 +41,7 @@ import AdminLogo from 'components/AdminLogo'; import MobileLogo from 'components/MobileLogo'; import Profile from './HeaderContent/Profile'; import "assets/style/navbarStyles.css"; -import { isUserLoggedIn, isGLDLoggedIn, isPrimaryLoggedIn } from "utils/Utils"; +import { isUserLoggedIn, isGLDLoggedIn, isPrimaryLoggedIn, isCreditorLoggedIn } from "utils/Utils"; import { handleLogoutFunction } from 'auth/index'; // assets @@ -49,7 +49,7 @@ import { handleLogoutFunction } from 'auth/index'; // import { AppBar } from '../../../../node_modules/@mui/material/index'; import { Link } from "react-router-dom"; import LocaleSelector from "./HeaderContent/LocaleSelector"; -import {FormattedMessage} from "react-intl"; +import { FormattedMessage } from "react-intl"; const drawerWidth = 240; @@ -83,13 +83,13 @@ function Header(props) {
  • - Application + Application
  • Proof
  • - Payment + Payment
    • Payment Record @@ -106,22 +106,22 @@ function Header(props) {
  • - Client + Client
    • - Users (GLD) + Users (GLD)
    • - Users (Individual) + Users (Individual)
    • - Users (Organisation) + Users (Organisation)
    • - Organisation + Organisation
    • - User Group + User Group
    @@ -137,27 +137,30 @@ function Header(props) {
  • - +
  • - +
  • - +
  • - {isPrimaryLoggedIn() ? + {isCreditorLoggedIn() ? <> - 付款記錄 + + 付款記錄 + +
    • - +
    • @@ -167,30 +170,38 @@ function Header(props) { : - + }
    • - - console.log(event)}> - - - - - {!isPrimaryLoggedIn() ? -
        -
      • - - - - - -
      • -
      + {isPrimaryLoggedIn() ? + <> + + console.log(event)}> + + + + +
        +
      • + + + + + +
      • +
      + : - <> + <> + + console.log(event)}> + + + + }
    • {/*
    • @@ -204,14 +215,14 @@ function Header(props) {
    • - +
    • - +
    • @@ -307,7 +318,7 @@ function Header(props) { - + @@ -328,10 +339,10 @@ function Header(props) { { - isGLDLoggedIn()? - - : - + isGLDLoggedIn() ? + + : + } @@ -350,7 +361,7 @@ function Header(props) { keepMounted: true, // Better open performance on mobile. }} sx={{ - display: {sm: 'block', md: 'none' }, + display: { sm: 'block', md: 'none' }, '& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth }, }} > @@ -372,7 +383,7 @@ function Header(props) { - + @@ -392,7 +403,7 @@ function Header(props) { - + @@ -412,7 +423,7 @@ function Header(props) { - + {/* */} diff --git a/src/utils/Utils.js b/src/utils/Utils.js index bb33e6f..7dfe0eb 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -83,6 +83,11 @@ export const isPrimaryLoggedIn = () =>{ return JSON.parse(localStorage.getItem('userData')).role === 'primary' } } +export const isCreditorLoggedIn = () =>{ + if (localStorage.getItem('userData') != null){ + return JSON.parse(localStorage.getItem('userData')).creditor + } +} /** ** This function is used for demo purpose route navigation ** In real app you won't need this function because your app will navigate to same route for each users regardless of ability