Skip to content

Commit

Permalink
fix: fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Apr 27, 2023
1 parent 7ad3ba4 commit afad01b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
8 changes: 3 additions & 5 deletions apps/storefront/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,9 @@ export default function App() {
isAgenting,
}

if (!customerId || isRelogin) {
const info = await getCurrentCustomerInfo(dispatch)
if (info) {
userInfo.role = info?.role
}
const info = await getCurrentCustomerInfo(dispatch)
if (info) {
userInfo.role = info?.role
}

// background login enter judgment and refresh
Expand Down
5 changes: 5 additions & 0 deletions apps/storefront/src/components/loadding/B3PageMask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export function B3PageMask() {
}

export const showPageMask = (dispatch: DispatchProps, isShow: boolean) => {
const b2bStyleElement = document.getElementById('b2b-account-page-hide-body')
if (b2bStyleElement) {
b2bStyleElement.innerHTML = ''
}

dispatch({
type: 'common',
payload: {
Expand Down
4 changes: 3 additions & 1 deletion apps/storefront/src/pages/accountSetting/AccountSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ function AccountSetting() {
const { accountB2BFormFields, passwordModified } =
getAccountSettingFiles(12)

const contactInformation = accountFormFields.contactInformation.filter(
const contactInformation = (
accountFormFields?.contactInformation || []
).filter(
(item: Partial<Fields>) =>
item.fieldId !== 'field_email_marketing_newsletter'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Box } from '@mui/material'
import { CustomButton } from '@/components'
import { useMobile } from '@/hooks'
import { b2bQuoteCheckout, bcQuoteCheckout } from '@/shared/service/b2b'
import { snackbar } from '@/utils'

interface QuoteDetailFooterProps {
quoteId: string
Expand Down Expand Up @@ -40,8 +39,8 @@ function QuoteDetailFooter(props: QuoteDetailFooterProps) {
} = res

window.location.href = checkoutUrl
} catch (err: any) {
snackbar.error(err)
} catch (err) {
console.error(err)
}
}

Expand Down
25 changes: 24 additions & 1 deletion apps/storefront/src/pages/quote/components/QuoteTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { forwardRef, Ref, useImperativeHandle, useRef, useState } from 'react'
import { Delete, Edit } from '@mui/icons-material'
import { Box, styled, TextField, Typography } from '@mui/material'
import { ceil } from 'lodash'

import { B3PaginationTable } from '@/components/table/B3PaginationTable'
import { TableColumnItem } from '@/components/table/B3Table'
Expand Down Expand Up @@ -111,6 +112,7 @@ function QuoteTable(props: ShoppingDetailTableProps, ref: Ref<unknown>) {
isB2BUser,
updateSummary,
} = props
const quoteProductQtyMaxLimit = 1000000

const paginationTableRef = useRef<PaginationTableRefProps | null>(null)

Expand Down Expand Up @@ -151,6 +153,24 @@ function QuoteTable(props: ShoppingDetailTableProps, ref: Ref<unknown>) {
updateSummary()
}

const handleCheckProductQty = (
id: number | string,
value: number | string
) => {
let newQty = ceil(+value)
if (newQty === +value && newQty >= 1 && newQty <= quoteProductQtyMaxLimit)
return

if (value < 1) {
newQty = 1
}

if (value > quoteProductQtyMaxLimit) {
newQty = quoteProductQtyMaxLimit
}
handleUpdateProductQty(id, newQty)
}

const handleDeleteClick = (id: number | string) => {
const quoteDraftAllList = B3LStorage.get('b2bQuoteDraftList') || []

Expand Down Expand Up @@ -398,7 +418,10 @@ function QuoteTable(props: ShoppingDetailTableProps, ref: Ref<unknown>) {
pattern: '[0-9]*',
}}
onChange={(e) => {
handleUpdateProductQty(row.id, e.target.value)
handleUpdateProductQty(row.id, +e.target.value)
}}
onBlur={(e) => {
handleCheckProductQty(row.id, +e.target.value)
}}
/>
),
Expand Down
4 changes: 3 additions & 1 deletion apps/storefront/src/utils/b3Product/b3TaxRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ const getTaxRate = (taxClassId: number) => {

if (taxZoneRates.length) {
taxZoneRates.forEach((taxZoneRate: TaxZoneRatesProps) => {
if (taxZoneRate.rates[0].priority === 1) {
if (taxZoneRate.rates.length > 0 && taxZoneRate.rates[0].priority === 1) {
taxRates = taxZoneRate?.rates[0]?.classRates || []
} else {
taxRates = []
}
})
}
Expand Down

0 comments on commit afad01b

Please sign in to comment.