Skip to content

Commit

Permalink
fix: rename B3B2BToken to B2BToken
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-marco authored and kris-liu-smile committed Jul 31, 2023
1 parent e0071f4 commit e947abe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/storefront/src/components/HeadlessController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function HeadlessController({
),
}
},
getB2BToken: () => B3SStorage.get('B3B2BToken') || '',
getB2BToken: () => B3SStorage.get('B2BToken') || '',
setMasqueradeCompany: (companyId) =>
startMasquerade({
dispatch,
Expand All @@ -155,7 +155,7 @@ export default function HeadlessController({
getCurrentCustomerInfo(dispatch, customerJWTToken),
graphqlBCProxy: B3Request.graphqlBCProxy,
loginWithB2BStorefrontToken: (b2bStorefrontJWTToken: string) =>
B3SStorage.set('B3B2BToken', b2bStorefrontJWTToken),
B3SStorage.set('B2BToken', b2bStorefrontJWTToken),
},
shoppingList: {
addProductFromPage: () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/pages/invoice/Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ function Payment() {
useEffect(() => {
const init = async () => {
setLoadding(true)
const B3B2BToken = B3SStorage.get('B3B2BToken')
const B2BToken = B3SStorage.get('B2BToken')

if (!B3B2BToken) {
if (!B2BToken) {
setOpen(true)
setLoadding(false)
return
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/src/shared/service/request/b3Fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function request<T>(path: string, config?: T & Config, type?: string) {
'x-xsrf-token': getCookie('XSRF-TOKEN'),
}
: {
authToken: `${B3SStorage.get('B3B2BToken') || ''}`,
authToken: `${B3SStorage.get('B2BToken') || ''}`,
}

const {
Expand Down Expand Up @@ -99,7 +99,7 @@ const B3Request = {
*/
graphqlB2B: function post<T>(data: T, customMessage = false): Promise<any> {
const config = {
Authorization: `Bearer ${B3SStorage.get('B3B2BToken') || ''}`,
Authorization: `Bearer ${B3SStorage.get('B2BToken') || ''}`,
}
return graphqlRequest(RequestType.B2BGraphql, data, config, customMessage)
},
Expand Down
10 changes: 5 additions & 5 deletions apps/storefront/src/utils/loginInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const clearCurrentCustomerInfo = async (dispatch: DispatchProps) => {
B3SStorage.set('B3Role', '')
B3SStorage.set('isB2BUser', false)
B3SStorage.set('currentCustomerJWTToken', '')
B3SStorage.set('B3B2BToken', false)
B3SStorage.set('B2BToken', false)
B3SStorage.set('B3UserId', '')

B3SStorage.set('salesRepCompanyName', '')
Expand Down Expand Up @@ -162,8 +162,8 @@ const getB2BTokenWithJWTToken = async (userType: number, jwtToken: string) => {
if (userType === 3) {
const data = await getB2BToken(jwtToken, channelId)
if (data) {
const B3B2BToken = (data as B2BToken).authorization.result.token
B3SStorage.set('B3B2BToken', B3B2BToken)
const B2BToken = (data as B2BToken).authorization.result.token
B3SStorage.set('B2BToken', B2BToken)
const { loginType } = (data as B2BToken).authorization.result

sessionStorage.setItem('loginType', JSON.stringify(loginType || null))
Expand Down Expand Up @@ -195,9 +195,9 @@ export const getCompanyInfo = async (
const realRole =
B3SStorage.get('realRole') === 0 ? 0 : B3SStorage.get('realRole') || role

const B3B2BToken = B3SStorage.get('B3B2BToken')
const B2BToken = B3SStorage.get('B2BToken')
const roles = [0, 1, 2]
if (!B3B2BToken || !roles.includes(+realRole)) return companyInfo
if (!B2BToken || !roles.includes(+realRole)) return companyInfo

if (userType === 3 && +realRole !== 3) {
const { userCompany } = await getUserCompany(+id)
Expand Down

0 comments on commit e947abe

Please sign in to comment.