Skip to content

Commit

Permalink
fix: sale rep permisstion
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-liu-smile committed Mar 10, 2023
1 parent db32fe4 commit 8147baa
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/storefront/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default function App() {
}, [])

useEffect(() => {
const isRelogin = sessionStorage.getItem('isreLogin')
const isRelogin = sessionStorage.getItem('isReLogin') === 'true'
loginAndRegister()
const init = async () => {
// bc token
Expand Down Expand Up @@ -206,7 +206,7 @@ export default function App() {
gotoAllowedAppPage(+userInfo.role, userInfo.isAgenting, gotoPage)
}

sessionStorage.removeItem('isreLogin')
sessionStorage.removeItem('isReLogin')
showPageMask(false)
}

Expand Down
16 changes: 15 additions & 1 deletion apps/storefront/src/components/B3Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import {
useRef,
ReactElement,
ReactNode,
useContext,
} from 'react'

import {
useMobile,
useScrollBar,
} from '@/hooks'

import {
GlobaledContext,
} from '@/shared/global'

import {
B3Sping,
} from './spin/B3Sping'
Expand Down Expand Up @@ -81,6 +86,12 @@ export const B3Dialog:<T> ({

const [isMobile] = useMobile()

const {
state: {
isAgenting,
},
} = useContext(GlobaledContext)

const handleSaveClick = () => {
if (handRightClick) {
if (row) handRightClick(row)
Expand Down Expand Up @@ -132,7 +143,10 @@ export const B3Dialog:<T> ({
sx={
isShowBordered ? {
borderTop: '1px solid #D9DCE9',
} : {}
marginBottom: isAgenting ? '52px' : '0',
} : {
marginBottom: isAgenting ? '52px' : '0',
}
}
>
{
Expand Down
7 changes: 4 additions & 3 deletions apps/storefront/src/components/B3HoverButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const B3HoverButton = (props: B3HoverButtonProps) => {
const {
state: {
isAgenting,
salesRepCompanyName,
},
} = useContext(GlobaledContext)

Expand Down Expand Up @@ -78,14 +79,14 @@ export const B3HoverButton = (props: B3HoverButtonProps) => {
>

{
!isOpen && productQuoteEnabled && (
!isOpen && productQuoteEnabled && !href.includes('/cart') && (
<Button
sx={{
backgroundColor: '#ED6C02',
height: '42px',
}}
onClick={() => {
B3SStorage.set('nextPath', '/')
// B3SStorage.set('nextPath', '/')
setOpenPage({
isOpen: true,
openUrl: '/quoteDraft',
Expand Down Expand Up @@ -115,7 +116,7 @@ export const B3HoverButton = (props: B3HoverButtonProps) => {
variant="contained"
startIcon={<GroupIcon />}
>
Mitsubishi
{salesRepCompanyName}
</Button>
)
}
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/components/B3MasquradeGobalTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const B3MasquradeGobalTip = (props: B3MasquradeGobalTipProps) => {
} else {
await superAdminEndMasquerade(+salesRepCompanyId, +B3UserId)
B3SStorage.delete('isAgenting')
B3SStorage.set('isB2BUser', false)
// B3SStorage.set('isB2BUser', false)
B3SStorage.delete('salesRepCompanyId')
B3SStorage.delete('salesRepCompanyName')
dispatch(
Expand Down Expand Up @@ -241,7 +241,7 @@ export const B3MasquradeGobalTip = (props: B3MasquradeGobalTipProps) => {
m: '0 15px 0 10px',
}}
>
Mitsubishi
{salesRepCompanyName}
</Box>
</Box>

Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/pages/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Dashboard = () => {
B3SStorage.set('isAgenting', true)
B3SStorage.set('salesRepCompanyId', id)
B3SStorage.set('salesRepCompanyName', companyName)
B3SStorage.set('isB2BUser', true)
// B3SStorage.set('isB2BUser', true)

dispatch(
{
Expand Down Expand Up @@ -149,7 +149,7 @@ const Dashboard = () => {
showPageMask(true)
await superAdminEndMasquerade(+salesRepCompanyId, +B3UserId)
B3SStorage.delete('isAgenting')
B3SStorage.set('isB2BUser', false)
// B3SStorage.set('isB2BUser', false)
B3SStorage.delete('salesRepCompanyId')
B3SStorage.delete('salesRepCompanyName')
dispatch(
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/utils/loginInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export const getCurrentCustomerInfo = async (dispatch: DispatchProps) => {
B3SStorage.set('B3EmailAddress', emailAddress)
B3SStorage.set('B3UserId', id)
B3SStorage.set('B3Role', userType === 3 ? role : 99)
B3SStorage.set('isB2BUser', role === 0 || role === 1 || role === 2 || (role === 3 && agentInfo.isAgenting))
B3SStorage.set('isB2BUser', userType === 3)

dispatch({
type: 'common',
Expand Down

0 comments on commit 8147baa

Please sign in to comment.