diff --git a/apps/storefront/src/App.tsx b/apps/storefront/src/App.tsx
index fc470f00..4ab88e82 100644
--- a/apps/storefront/src/App.tsx
+++ b/apps/storefront/src/App.tsx
@@ -229,15 +229,21 @@ export default function App() {
useEffect(() => {
const handleHashChange = () => {
const { hash } = window.location
- if (!isOpen && hash) {
+ if (hash) {
const url = hash.split('#')[1]
- if (url !== '/') {
+ if (url && url !== '/') {
setOpenPage({
isOpen: true,
openUrl: url,
})
+ return
}
}
+
+ setOpenPage({
+ isOpen: false,
+ openUrl: '',
+ })
}
window.addEventListener('hashchange', handleHashChange)
@@ -256,11 +262,7 @@ export default function App() {
customStyles={CUSTOM_STYLES}
>
{isOpen ? (
-
+
) : null}
diff --git a/apps/storefront/src/components/layout/B3RenderRouter.tsx b/apps/storefront/src/components/layout/B3RenderRouter.tsx
index c7e2bbc9..11f128b6 100644
--- a/apps/storefront/src/components/layout/B3RenderRouter.tsx
+++ b/apps/storefront/src/components/layout/B3RenderRouter.tsx
@@ -29,11 +29,10 @@ import B3LayoutTip from './B3LayoutTip'
interface B3RenderRouterProps {
setOpenPage: Dispatch>
openUrl?: string
- isOpen?: boolean
}
export default function B3RenderRouter(props: B3RenderRouterProps) {
- const { setOpenPage, openUrl, isOpen } = props
+ const { setOpenPage, openUrl } = props
const { state: globaledState } = useContext(GlobaledContext)
@@ -43,24 +42,6 @@ export default function B3RenderRouter(props: B3RenderRouterProps) {
const navigate = useNavigate()
- useEffect(() => {
- if (location && isOpen) {
- if (location.pathname === '/') {
- setOpenPage({
- isOpen: false,
- openUrl: '',
- })
- } else {
- setOpenPage({
- isOpen: true,
- openUrl: location.pathname,
- })
- if (location.state && location.pathname.includes('dashboard'))
- location.state = null
- }
- }
- }, [location])
-
useEffect(() => {
if (openUrl && openUrl === '/dashboard?closeMasqurade=1') {
navigate('/dashboard', {
@@ -68,6 +49,8 @@ export default function B3RenderRouter(props: B3RenderRouterProps) {
closeMasqurade: '1',
},
})
+ } else if (openUrl === '/dashboard') {
+ location.state = null
}
}, [openUrl])
diff --git a/apps/storefront/src/hooks/dom/utils.ts b/apps/storefront/src/hooks/dom/utils.ts
index 53bd493f..4d0d868f 100644
--- a/apps/storefront/src/hooks/dom/utils.ts
+++ b/apps/storefront/src/hooks/dom/utils.ts
@@ -128,7 +128,7 @@ const gotoQuoteDraft = (setOpenPage: DispatchProps) => {
isOpen: true,
openUrl: '/quoteDraft',
params: {
- quoteBtn: 'open',
+ quoteBtn: 'add',
},
})
}
diff --git a/apps/storefront/src/pages/dashboard/Dashboard.tsx b/apps/storefront/src/pages/dashboard/Dashboard.tsx
index 5530fe88..4254a8ac 100644
--- a/apps/storefront/src/pages/dashboard/Dashboard.tsx
+++ b/apps/storefront/src/pages/dashboard/Dashboard.tsx
@@ -1,5 +1,13 @@
-import { MouseEvent, useContext, useEffect, useState } from 'react'
+import {
+ Dispatch,
+ MouseEvent,
+ SetStateAction,
+ useContext,
+ useEffect,
+ useState,
+} from 'react'
import { useLocation } from 'react-router-dom'
+import type { OpenPageState } from '@b3/hooks'
import MoreHorizIcon from '@mui/icons-material/MoreHoriz'
import { Box, IconButton, Menu, MenuItem } from '@mui/material'
import { styled } from '@mui/material/styles'
@@ -31,6 +39,10 @@ interface B3MeanProps {
endActing: () => void
}
+interface DashboardProps {
+ setOpenPage: Dispatch>
+}
+
const StyledMenu = styled(Menu)(() => ({
'& .MuiPaper-elevation': {
boxShadow:
@@ -102,12 +114,14 @@ function B3Mean({
)
}
-function Dashboard() {
+function Dashboard(props: DashboardProps) {
const {
state: { customerId, B3UserId, salesRepCompanyId = 0 },
dispatch,
} = useContext(GlobaledContext)
+ const { setOpenPage } = props
+
const [currentSalesRepCompanyId, setCurrentSalesRepCompanyId] =
useState(+salesRepCompanyId)
@@ -161,6 +175,12 @@ function Dashboard() {
setIsRequestLoading(true)
await superAdminBeginMasquerade(id || currentSalesRepCompanyId, +B3UserId)
await setMasqueradeInfo()
+
+ setOpenPage({
+ isOpen: true,
+ openUrl: '/dashboard',
+ })
+
setFilterData({
...filterData,
})
diff --git a/apps/storefront/src/pages/quote/QuoteDraft.tsx b/apps/storefront/src/pages/quote/QuoteDraft.tsx
index 92a6e119..a7c26323 100644
--- a/apps/storefront/src/pages/quote/QuoteDraft.tsx
+++ b/apps/storefront/src/pages/quote/QuoteDraft.tsx
@@ -549,7 +549,7 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) {
}
const backText = () => {
- let text = 'Back to quote lists'
+ let text = +role === 100 ? 'Back' : 'to quote lists'
if (openAPPParams?.quoteBtn === 'open') {
text = 'Back'
} else if (openAPPParams?.quoteBtn === 'add') {
@@ -594,7 +594,7 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) {
alignItems: 'center',
}}
onClick={() => {
- if (openAPPParams?.quoteBtn) {
+ if (openAPPParams?.quoteBtn || +role === 100) {
navigate('/')
setOpenPage({
isOpen: false,
diff --git a/apps/storefront/src/pages/registered/Registered.tsx b/apps/storefront/src/pages/registered/Registered.tsx
index 67feb2b1..1deffbe3 100644
--- a/apps/storefront/src/pages/registered/Registered.tsx
+++ b/apps/storefront/src/pages/registered/Registered.tsx
@@ -290,6 +290,7 @@ function Registered(props: RegisteredProps) {