Skip to content

Commit

Permalink
fix: bug BUN-721
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-liu-smile committed Mar 10, 2023
1 parent 1f94633 commit fb050be
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
6 changes: 3 additions & 3 deletions apps/storefront/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
B3RenderRouter,
B3MasquradeGobalTip,
B3HoverButton,
CheckoutTip,
// CheckoutTip,
} from '@/components'

import {
Expand Down Expand Up @@ -273,9 +273,9 @@ export default function App() {
productQuoteEnabled={productQuoteEnabled}
setOpenPage={setOpenPage}
/>
<CheckoutTip
{/* <CheckoutTip
setOpenPage={setOpenPage}
/>
/> */}
</>

)
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/components/B3HoverButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const B3HoverButton = (props: B3HoverButtonProps) => {
height: '42px',
}}
onClick={() => {
// B3SStorage.set('nextPath', '/')
B3SStorage.set('nextPath', '/')
setOpenPage({
isOpen: true,
openUrl: '/quoteDraft',
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/components/layout/B3Mainheader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const B3Mainheader = ({
color: '#333333',
}}
>
{companyInfo?.companyName || salesRepCompanyName}
{companyInfo?.companyName || salesRepCompanyName || 'Super admin'}

{/* <B3DropDown
title="Renteach building"
Expand Down
15 changes: 8 additions & 7 deletions apps/storefront/src/pages/accountSetting/AccountSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ const AccountSetting = () => {

const companyId = role === 3 && isAgenting ? +salesRepCompanyId : +companyInfoId

const isBCUser = !isB2BUser || (role === 3 && !isAgenting)

useEffect(() => {
const init = async () => {
try {
setLoadding(true)

const isBCUser = !isB2BUser || (role === 3 && !isAgenting)
const accountFormAllFields = await getB2BAccountFormFields(isBCUser ? 1 : 2)

const fn = !isBCUser ? getB2BAccountSettings : getBCAccountSettings
Expand All @@ -188,7 +189,7 @@ const AccountSetting = () => {
additionalInformation,
} = accountFormFields

if (isB2BUser) {
if (!isBCUser) {
contactInformation.forEach((item: Partial<Fields>) => {
if (deCodeField(item?.name || '') === 'first_name') {
item.default = accountSettings.firstName
Expand Down Expand Up @@ -283,8 +284,8 @@ const AccountSetting = () => {

const validateEmailValue = async (emailValue: string) => {
if (customer.emailAddress === trim(emailValue)) return true
const fn = isB2BUser ? checkUserEmail : checkUserBCEmail
const key = isB2BUser ? 'userEmailCheck' : 'customerEmailCheck'
const fn = !isBCUser ? checkUserEmail : checkUserBCEmail
const key = !isBCUser ? 'userEmailCheck' : 'customerEmailCheck'

const {
[key]: {
Expand All @@ -295,7 +296,7 @@ const AccountSetting = () => {
channelId: currentChannelId,
})

const isValid = isB2BUser ? [1].includes(userType) : ![2].includes(userType)
const isValid = !isBCUser ? [1].includes(userType) : ![2].includes(userType)

if (!isValid) {
setError('email', {
Expand Down Expand Up @@ -342,7 +343,7 @@ const AccountSetting = () => {
setLoadding(true)

try {
const isValid = isB2BUser ? await validateEmailValue(data.email) : true
const isValid = !isBCUser ? await validateEmailValue(data.email) : true

const emailFlag = emailValidation(data)

Expand All @@ -354,7 +355,7 @@ const AccountSetting = () => {
const param: Partial<ParamProps> = {}
param.formFields = []
let flag = true
if (isB2BUser) {
if (!isBCUser) {
Object.keys(data).forEach((key: string) => {
decryptionFields.forEach((item: Partial<Fields>) => {
if (key === item.name) {
Expand Down
22 changes: 10 additions & 12 deletions apps/storefront/src/shared/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ export interface RouteFirstLevelItem extends RouteItemBasic{
}

const routes: RouteItem[] = [
{
path: '/',
name: 'Dashboard',
wsKey: 'router-orders',
isMenuItem: true,
component: Dashboard,
permissions: [3, 4],
isTokenLogin: true,
},
{
path: '/orders',
name: 'My orders',
Expand Down Expand Up @@ -200,15 +209,6 @@ const routes: RouteItem[] = [
permissions: [0, 1, 2, 3, 99, 100],
isTokenLogin: true,
},
{
path: '/',
name: 'Dashboard',
wsKey: 'router-orders',
isMenuItem: true,
component: Dashboard,
permissions: [3, 4],
isTokenLogin: true,
},
]

const firstLevelRouting: RouteFirstLevelItem[] = [
Expand Down Expand Up @@ -258,8 +258,6 @@ const getAllowedRoutes = (globalState: GlobalState): RouteItem[] => {
cartQuoteEnabled,
} = globalState

console.log(isB2BUser, role, isAgenting, storefrontConfig, productQuoteEnabled, cartQuoteEnabled)

return routes.filter((item: RouteItem) => {
const {
permissions = [],
Expand Down Expand Up @@ -302,7 +300,7 @@ const gotoAllowedAppPage = (role: number, isAgenting:boolean, gotoPage: (url: st
hash,
} = window.location
let url = hash.split('#')[1] || ''
if (!url && role !== 100) url = (role === 3 && !isAgenting) ? '/' : '/orders'
if (!url && role !== 100) url = role === 3 ? '/' : '/orders'
const flag = routes.some((item: RouteItem) => matchPath(item.path, url) && item.permissions.includes(role))

const isFirstLevelFlag = firstLevelRouting.some((item: RouteFirstLevelItem) => matchPath(item.path, url))
Expand Down

0 comments on commit fb050be

Please sign in to comment.