Skip to content

Commit

Permalink
fix: issue with Super Admin logging out after completing a quote BUN-…
Browse files Browse the repository at this point in the history
…1172
  • Loading branch information
kris-liu-smile committed Jun 27, 2023
1 parent 93ee9ee commit b3cdf86
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions apps/storefront/src/components/layout/B3AccountInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Box } from '@mui/material'

import { useMobile } from '@/hooks'
import { GlobaledContext } from '@/shared/global'
import { superAdminEndMasquerade } from '@/shared/service/b2b'
import { B3SStorage } from '@/utils'

import B3DropDown from '../B3DropDown'

Expand All @@ -29,14 +31,37 @@ export default function B3AccountInfo({ closeSidebar }: B3AccountInfoProps) {
const {
state: {
customer: { firstName = '', lastName = '' },
B3UserId,
salesRepCompanyId = 0,
isAgenting,
},
dispatch,
} = useContext(GlobaledContext)

const navigate = useNavigate()

const handleItemClick = (item: ListProps) => {
const handleItemClick = async (item: ListProps) => {
if (item.key === 'logout') {
navigate('/login?loginFlag=3')
try {
if (isAgenting) {
await superAdminEndMasquerade(+salesRepCompanyId, +B3UserId)

B3SStorage.delete('isAgenting')
B3SStorage.delete('salesRepCompanyId')
B3SStorage.delete('salesRepCompanyName')

dispatch({
type: 'common',
payload: {
salesRepCompanyId: '',
salesRepCompanyName: '',
isAgenting: false,
},
})
}
} finally {
navigate('/login?loginFlag=3')
}
} else if (item.type === 'path') {
navigate(item.key)
}
Expand Down

0 comments on commit b3cdf86

Please sign in to comment.