@vtex/faststore-plugin-buyer-portal 1.0.22 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "dependencies": {},
@@ -1,7 +1,5 @@
1
1
  import { AddressData, AddressSummaryData } from "../types/AddressData";
2
2
  import { statusFilters } from "../utils/search";
3
- import { API_URL } from '../utils/constants';
4
- import storeConfig from '../../../../discovery.config'
5
3
  import { getApiUrl } from "../utils/api";
6
4
 
7
5
  export type GetAddressesServiceProps = {
@@ -1,7 +1,5 @@
1
1
  import { ContractData } from "../types/ContractData";
2
2
  import { statusFilters } from "../utils/search";
3
- import { API_URL } from '../utils/constants';
4
- import storeConfig from '../../../../discovery.config'
5
3
  import { getApiUrl } from "../utils/api";
6
4
 
7
5
 
package/src/utils/api.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { API_URL } from "./constants"
2
- import storeConfig from '../../../../discovery.config'
3
2
 
4
3
 
5
4
  export function getApiUrl(operation: string, customerId: string) {
6
- return `${API_URL(storeConfig?.secureSubdomain ?? '', operation)}${customerId ? `/${customerId}` : ''}`
5
+ return `${API_URL(`https://b2bfaststore.myvtex.com/` ?? '', operation)}${customerId ? `/${customerId}` : ''}`
7
6
  }
@@ -17,13 +17,17 @@ export function getAuthCookie(data: LoaderData) {
17
17
  export function getCustomerIdFromCookieServerSide(data: LoaderData) {
18
18
  const authCookie = getAuthCookie(data)
19
19
 
20
+ if (!authCookie || authCookie === '') {
21
+ return 'TempCustomerId'
22
+ }
23
+
20
24
  const parsedCookie = parseJwt(authCookie)
21
25
 
22
26
  return parsedCookie.customerId
23
27
  }
24
28
 
25
29
  export function getCookieAsString(cookie: Record<string, string>) {
26
- return JSON.stringify(cookie).replace(/[{}]/g, '')
30
+ return JSON.stringify(cookie).replace(/[{}]/g, '') ?? ''
27
31
  }
28
32
 
29
33
  function parseJwt(token: string) {