Skip to content

Commit

Permalink
fix: invalid signature error
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and CarlLiu2023 committed Jun 6, 2023
1 parent a4e3417 commit 66fdf5a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 32 deletions.
16 changes: 9 additions & 7 deletions apps/storefront/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -256,11 +262,7 @@ export default function App() {
customStyles={CUSTOM_STYLES}
>
{isOpen ? (
<B3RenderRouter
openUrl={openUrl}
isOpen={isOpen}
setOpenPage={setOpenPage}
/>
<B3RenderRouter openUrl={openUrl} setOpenPage={setOpenPage} />
) : null}
</ThemeFrame>
</div>
Expand Down
23 changes: 3 additions & 20 deletions apps/storefront/src/components/layout/B3RenderRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ import B3LayoutTip from './B3LayoutTip'
interface B3RenderRouterProps {
setOpenPage: Dispatch<SetStateAction<OpenPageState>>
openUrl?: string
isOpen?: boolean
}

export default function B3RenderRouter(props: B3RenderRouterProps) {
const { setOpenPage, openUrl, isOpen } = props
const { setOpenPage, openUrl } = props

const { state: globaledState } = useContext(GlobaledContext)

Expand All @@ -43,31 +42,15 @@ 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', {
state: {
closeMasqurade: '1',
},
})
} else if (openUrl === '/dashboard') {
location.state = null
}
}, [openUrl])

Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/hooks/dom/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const gotoQuoteDraft = (setOpenPage: DispatchProps) => {
isOpen: true,
openUrl: '/quoteDraft',
params: {
quoteBtn: 'open',
quoteBtn: 'add',
},
})
}
Expand Down
24 changes: 22 additions & 2 deletions apps/storefront/src/pages/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -31,6 +39,10 @@ interface B3MeanProps {
endActing: () => void
}

interface DashboardProps {
setOpenPage: Dispatch<SetStateAction<OpenPageState>>
}

const StyledMenu = styled(Menu)(() => ({
'& .MuiPaper-elevation': {
boxShadow:
Expand Down Expand Up @@ -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<number>(+salesRepCompanyId)

Expand Down Expand Up @@ -161,6 +175,12 @@ function Dashboard() {
setIsRequestLoading(true)
await superAdminBeginMasquerade(id || currentSalesRepCompanyId, +B3UserId)
await setMasqueradeInfo()

setOpenPage({
isOpen: true,
openUrl: '/dashboard',
})

setFilterData({
...filterData,
})
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/pages/quote/QuoteDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -594,7 +594,7 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) {
alignItems: 'center',
}}
onClick={() => {
if (openAPPParams?.quoteBtn) {
if (openAPPParams?.quoteBtn || +role === 100) {
navigate('/')
setOpenPage({
isOpen: false,
Expand Down
1 change: 1 addition & 0 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ function Registered(props: RegisteredProps) {
<B3Sping
isSpinning={isLoading}
tip={b3Lang('intl.global.tips.loading')}
transparency=".75"
>
<Box
sx={{
Expand Down

0 comments on commit 66fdf5a

Please sign in to comment.