Skip to content

Commit

Permalink
feat: 1.change the order in which digits get added in the Invoice "Am…
Browse files Browse the repository at this point in the history
…ount to Pay"

2.add Improved error messaging when logging in while the store is in "Prelaunch" Status
BUN-1406,BUN-1411
  • Loading branch information
kris-liu-smile authored and CarlLiu2023 committed Sep 8, 2023
1 parent cea2d30 commit aa45d5c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
9 changes: 3 additions & 6 deletions apps/storefront/src/pages/invoice/Invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,10 @@ function Invoice() {
-decimalPlaces
)}`
}
} else if (result.length > 1) {
result = `${val.slice(0, 1)}.${val.slice(-1)}`
} else {
const movePoint = result.length - +decimalPlaces
if (movePoint > 0) {
result = `${val.slice(0, -decimalPlaces)}.${val.slice(-decimalPlaces)}`
} else {
result = `.${val}`
}
result = `${val}`
}

handleSetSelectedInvoiceAccount(result, id)
Expand Down
43 changes: 36 additions & 7 deletions apps/storefront/src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ interface RegisteredProps {
setOpenPage: Dispatch<SetStateAction<OpenPageState>>
}

type AlertColor = 'success' | 'info' | 'warning' | 'error'

export default function Login(props: RegisteredProps) {
const [isLoading, setLoading] = useState(true)
const [isMobile] = useMobile()
Expand Down Expand Up @@ -180,13 +182,35 @@ export default function Login(props: RegisteredProps) {
case '4':
str = b3Lang('login.loginTipInfo.accountincorrect')
break
case '5':
str = b3Lang('login.loginTipInfo.accountPrelaunch')
break
default:
str = ''
}
}
return str
}

const setTipType = (flag: string): AlertColor | undefined => {
if (!flag) return undefined
let tipType: AlertColor = 'success'
switch (flag) {
case '1':
tipType = 'error'
break
case '4':
tipType = 'error'
break
case '5':
tipType = 'warning'
break
default:
tipType = 'success'
}
return tipType
}

const getforcePasswordReset = async (email: string) => {
const {
companyUserInfo: {
Expand Down Expand Up @@ -220,8 +244,18 @@ export default function Login(props: RegisteredProps) {
pass: data.password,
}
const { data: bcData, errors } = await bcLogin(getBCFieldsValue)

if (errors?.length || !bcData) {
if (errors?.length) {
const { message } = errors[0]
if (
message ===
'Operation cannot be performed as the storefront channel is not live'
) {
setLoginFlag('5')
setLoading(false)
return
}
}
getforcePasswordReset(data.emailAddress)
} else {
const info = await getCurrentCustomerInfo(dispatch)
Expand Down Expand Up @@ -276,12 +310,7 @@ export default function Login(props: RegisteredProps) {
margin: '30px 0 0 0',
}}
>
<Alert
severity={
flag === '1' || flag === '4' ? 'error' : 'success'
}
variant="filled"
>
<Alert severity={setTipType(flag)} variant="filled">
{tipInfo(flag, loginAccount?.emailAddress || '')}
</Alert>
</Box>
Expand Down
1 change: 1 addition & 0 deletions packages/lang/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
"login.loginTipInfo.receivePassword": "If the entered email address is associated with this store, you will receive a password reset email. If you don't receive this e-mail, please check your junk mail folder or contact us for further assistance.",
"login.loginTipInfo.loggedOutLogin": "You've been logged out of your account successfully.",
"login.loginTipInfo.accountincorrect": "Your email address or password is incorrect. Please try again. If you've forgotten your sign in details, just click the 'Forgot your password?' link below.",
"login.loginTipInfo.accountPrelaunch": "You can not login to the Buyer Portal while the store is in prelaunch or maintenance mode. Please set the store live, or login inside the customer admin panel.",
"login.loginText.forgotPasswordText": "Forgot your password?",
"login.loginText.password": "Password",

Expand Down

0 comments on commit aa45d5c

Please sign in to comment.