diff --git a/apps/storefront/src/utils/loginInfo.ts b/apps/storefront/src/utils/loginInfo.ts index 60866dd9..e129e4be 100644 --- a/apps/storefront/src/utils/loginInfo.ts +++ b/apps/storefront/src/utils/loginInfo.ts @@ -6,7 +6,7 @@ import { getBCGraphqlToken, getUserCompany, } from '@/shared/service/b2b' -import { getBcCurrentJWT } from '@/shared/service/bc' +import { getBcCurrentJWT, getCustomerInfo } from '@/shared/service/bc' import { B3LStorage, B3SStorage, storeHash } from '@/utils' const { VITE_B2B_CLIENT_ID, VITE_LOCAL_DEBUG } = import.meta.env @@ -337,10 +337,16 @@ export const getCurrentCustomerInfo = async ( b2bToken?: string ) => { try { - const loginCustomer = B3SStorage.get('loginCustomer') + let loginCustomer = B3SStorage.get('loginCustomer') if (!loginCustomer) { - return undefined + const { + data: { customer }, + } = await getCustomerInfo() + + loginCustomer = customer + + if (!customer) return undefined } const {