@sonic-equipment/ui 243.0.0 → 245.0.0

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.
@@ -55,18 +55,14 @@ const DEV_LIKE = new Set([
55
55
  'sandbox',
56
56
  'sandbox-reverse-proxy',
57
57
  'storybook',
58
+ 'next-development',
58
59
  ]);
59
60
  const getAlgoliaIndex = (environment, languageCode) => {
60
- let algoliaIndexEnv = 'development';
61
+ let algoliaIndexEnv = 'production';
61
62
  const language = getLanguageForAlgoliaIndex(languageCode).toLowerCase();
62
63
  if (DEV_LIKE.has(environment)) {
63
64
  algoliaIndexEnv = 'development';
64
65
  }
65
- else {
66
- algoliaIndexEnv = process?.env.ALGOLIA_APP_ID?.includes('testing')
67
- ? 'development'
68
- : 'production';
69
- }
70
66
  const environmentIndex = algoliaIndexesPerEnvironment[algoliaIndexEnv];
71
67
  return {
72
68
  default: environmentIndex.default.replace(/<languageCode>/, language),
package/dist/config.js CHANGED
@@ -27,7 +27,22 @@ const configPerEnvironment = {
27
27
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
28
28
  env?.VITE_SHOP_API_URL || 'https://localhost:8000',
29
29
  }),
30
- next: () => ({
30
+ 'next-development': () => ({
31
+ // @ts-expect-error: process is not defined in the browser
32
+ ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY || '',
33
+ // @ts-expect-error: process is not defined in the browser
34
+ ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID || '',
35
+ // @ts-expect-error: process is not defined in the browser
36
+ ALGOLIA_HOST: process.env.ALGOLIA_HOST || '',
37
+ // @ts-expect-error: process is not defined in the browser
38
+ BFF_API_URL: process.env.BFF_API_URL || '',
39
+ // @ts-expect-error: process is not defined in the browser
40
+ COOKIE_DOMAIN: process.env.COOKIE_DOMAIN || '',
41
+ HOME_PAGE_URL: '/',
42
+ // @ts-expect-error: process is not defined in the browser
43
+ SHOP_API_URL: process.env.SHOP_API_URL || '',
44
+ }),
45
+ 'next-production': () => ({
31
46
  // @ts-expect-error: process is not defined in the browser
32
47
  ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY || '',
33
48
  // @ts-expect-error: process is not defined in the browser
@@ -45,12 +60,11 @@ const configPerEnvironment = {
45
60
  production: () => ({
46
61
  ALGOLIA_API_KEY: 'e31a3a53449eceb4d0f9273b9bcd9759',
47
62
  ALGOLIA_APP_ID: '14CUFCVMAD',
48
- ALGOLIA_HOST: 'shop.sonic-equipment.com',
49
- BFF_API_URL: 'https://shop.sonic-equipment.com/api/v1/bff',
63
+ ALGOLIA_HOST: 'shopapi.sonic-equipment.com',
64
+ BFF_API_URL: 'https://shopapi.sonic-equipment.com/api/v1/bff',
50
65
  COOKIE_DOMAIN: '.sonic-equipment.com',
51
66
  HOME_PAGE_URL: 'https://sonic-equipment.com/',
52
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
53
- SHOP_API_URL: env?.VITE_SHOP_API_URL || 'https://shop.sonic-equipment.com',
67
+ SHOP_API_URL: 'https://shopapi.sonic-equipment.com',
54
68
  }),
55
69
  sandbox: () => ({
56
70
  ALGOLIA_API_KEY: 'e0edf30798a6b2e4e44fd25f0f2f9646',
@@ -70,15 +84,6 @@ const configPerEnvironment = {
70
84
  HOME_PAGE_URL: 'https://shop-accept.sonic-equipment.workers.dev/',
71
85
  SHOP_API_URL: 'https://shop-accept.sonic-equipment.workers.dev',
72
86
  }),
73
- 'spire-production': () => ({
74
- ALGOLIA_API_KEY: 'e31a3a53449eceb4d0f9273b9bcd9759',
75
- ALGOLIA_APP_ID: '14CUFCVMAD',
76
- ALGOLIA_HOST: 'shopapi.sonic-equipment.com',
77
- BFF_API_URL: 'https://shopapi.sonic-equipment.com/api/v1/bff',
78
- COOKIE_DOMAIN: '.sonic-equipment.com',
79
- HOME_PAGE_URL: 'https://sonic-equipment.com/',
80
- SHOP_API_URL: 'https://shopapi.sonic-equipment.com',
81
- }),
82
87
  storybook: () => ({
83
88
  ALGOLIA_API_KEY: 'e0edf30798a6b2e4e44fd25f0f2f9646',
84
89
  ALGOLIA_APP_ID: 'testing9VXJ0U4GSV',
@@ -91,6 +96,7 @@ const configPerEnvironment = {
91
96
  env?.VITE_SHOP_API_URL || 'https://localhost:8000',
92
97
  }),
93
98
  };
94
- const config = configPerEnvironment[environment]();
99
+ const configFunction = configPerEnvironment[environment];
100
+ const config = configFunction();
95
101
 
96
102
  export { config, configPerEnvironment };
package/dist/index.js CHANGED
@@ -464,7 +464,7 @@ export { childrenToText } from './shared/utils/children-to-text.js';
464
464
  export { getCssPropertyValue } from './shared/utils/css.js';
465
465
  export { formatDate } from './shared/utils/date.js';
466
466
  export { trackPropertyChange } from './shared/utils/debug.js';
467
- export { environment, environments } from './shared/utils/environment.js';
467
+ export { environment, environments, isProductionEnvironment } from './shared/utils/environment.js';
468
468
  export { EventEmitter } from './shared/utils/event-emitter.js';
469
469
  export { useGreeting } from './shared/utils/greeting.js';
470
470
  export { clone, deepMerge, isPlainObject, default as main, merge } from './shared/utils/merge.js';
@@ -20,7 +20,7 @@ import { useInvalidateCurrentCart } from '../../../../shared/api/storefront/hook
20
20
  import { useInvalidateAdyen } from '../../../../shared/api/storefront/hooks/payment/use-invalidate-adyen.js';
21
21
  import { useDataLayer } from '../../../../shared/ga/use-data-layer.js';
22
22
  import { getCurrencyCodeBySymbol } from '../../../../shared/model/currency.js';
23
- import { environment } from '../../../../shared/utils/environment.js';
23
+ import { isProductionEnvironment } from '../../../../shared/utils/environment.js';
24
24
  import { BillingAndInvoiceInformation } from '../../components/billing-and-invoice-information.js';
25
25
  import { useHasReturnedFromAdyen } from '../hooks/use-has-returned-from-adyen.js';
26
26
  import { AdyenPayment } from './adyen-payment.js';
@@ -244,7 +244,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
244
244
  MA: t('industry.MA'),
245
245
  OT: t('industry.OT'),
246
246
  /* eslint-enable sort-keys-fix/sort-keys-fix */
247
- }, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, { showLabel: true, defaultValue: cart.customerVatNumber, isDisabled: isDisabled, label: t('VAT Number'), minLength: 8, name: "customerVatNumber" }, `vat${Boolean(validationErrors.customerVatNumber)}`), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: isDisabled, isRequired: cart.requiresPoNumber, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && Object.keys(paymentMethodOptions).length > 1 && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: isDisabled, label: t('Payment method'), name: "paymentMethod", onChange: setSelectedPaymentMethod, options: paymentMethodOptions, selectedOption: selectedPaymentMethod, variant: "solid" })), isAdyenPayment && cart.billTo && (jsx(AdyenPayment, { amount: cart.orderGrandTotal, cartId: cart.trackId, countryCode: countryCode, currencyCode: currencyCode, customerId: cart.billTo.id, dropinRef: dropinRef, environment: environment === 'production' ? 'live' : 'test', isDisabled: isDisabled, onComplete: onComplete, onError: onError, orderAmount: cart.orderGrandTotal, returnUrl:
247
+ }, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, { showLabel: true, defaultValue: cart.customerVatNumber, isDisabled: isDisabled, label: t('VAT Number'), minLength: 8, name: "customerVatNumber" }, `vat${Boolean(validationErrors.customerVatNumber)}`), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: isDisabled, isRequired: cart.requiresPoNumber, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && Object.keys(paymentMethodOptions).length > 1 && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: isDisabled, label: t('Payment method'), name: "paymentMethod", onChange: setSelectedPaymentMethod, options: paymentMethodOptions, selectedOption: selectedPaymentMethod, variant: "solid" })), isAdyenPayment && cart.billTo && (jsx(AdyenPayment, { amount: cart.orderGrandTotal, cartId: cart.trackId, countryCode: countryCode, currencyCode: currencyCode, customerId: cart.billTo.id, dropinRef: dropinRef, environment: isProductionEnvironment ? 'live' : 'test', isDisabled: isDisabled, onComplete: onComplete, onError: onError, orderAmount: cart.orderGrandTotal, returnUrl:
248
248
  /* eslint-disable ssr-friendly/no-dom-globals-in-react-fc */
249
249
  typeof window === 'undefined'
250
250
  ? ''
@@ -24,10 +24,10 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
24
24
  const href = `${pathname}${search}`;
25
25
  const billToId = billTo?.id;
26
26
  const shipToId = shipTo?.id;
27
- const editBillToAddressUrl = environment === 'next'
27
+ const editBillToAddressUrl = environment.includes('next')
28
28
  ? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}?returnUrl=${encodeURIComponent(href)}`
29
29
  : paths.ACCOUNT_ADDRESSES;
30
- const editShipToAddressUrl = environment === 'next'
30
+ const editShipToAddressUrl = environment.includes('next')
31
31
  ? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${shipToId}?returnUrl=${encodeURIComponent(href)}`
32
32
  : paths.ACCOUNT_ADDRESSES;
33
33
  return (jsxs(Form, { id: EDIT_ADDRESS_FORM_ID, onSubmit: e => {
@@ -22,7 +22,7 @@ function removeElements(selector) {
22
22
  document?.querySelectorAll(selector).forEach(element => element.remove());
23
23
  }
24
24
  function PageMetaData(props) {
25
- if (environment === 'next')
25
+ if (environment.includes('next'))
26
26
  return null;
27
27
  if (typeof document === 'undefined')
28
28
  return null;
@@ -6,10 +6,10 @@ import { Details } from '../../display/details/details.js';
6
6
  import { StrokeRecentIcon } from '../../icons/stroke/stroke-recent-icon.js';
7
7
  import { useFormattedMessage } from '../../intl/use-formatted-message.js';
8
8
  import { Heading } from '../../typography/heading/heading.js';
9
- import { environment } from '../utils/environment.js';
9
+ import { isProductionEnvironment } from '../utils/environment.js';
10
10
  import styles from './default-error-view.module.css.js';
11
11
 
12
- function DefaultErrorView({ className, error, errorInfo, resetError, resetLabel, showErrorDetails = environment !== 'production', showReset, title, }) {
12
+ function DefaultErrorView({ className, error, errorInfo, resetError, resetLabel, showErrorDetails = !isProductionEnvironment, showReset, title, }) {
13
13
  const t = useFormattedMessage();
14
14
  return (jsxs("section", { className: clsx(styles['default-error-view'], className), children: [title && (jsx(Heading, { className: styles['title'], size: "s", tag: "h1", children: title || t('Something went wrong') })), jsx("p", { children: error.message || t('An unexpected error occured. Please try again.') }), showErrorDetails && (jsxs(Details, { className: styles['error-details'], lang: "en", summary: "Technical Details (only visible in development mode)", children: [jsx("output", { className: styles['error-kind'], children: error.toString() }), error.stack && (jsxs("div", { className: styles['error-info'], children: [jsx(Heading, { className: styles['error-info-title'], size: "xs", tag: "h2", children: "Stack:" }), jsx("pre", { className: styles['error-info-data'], children: error.stack })] })), errorInfo?.componentStack && (jsxs("div", { className: styles['component-info'], children: [jsx(Heading, { className: styles['error-info-title'], size: "xs", tag: "h2", children: "Component stack:" }), jsx("pre", { className: styles['error-info-data'], children: errorInfo.componentStack })] }))] })), showReset && resetError && (jsx(Button, { light: true, className: styles['reset-button'], color: "secondary", icon: jsx(StrokeRecentIcon, {}), onClick: resetError, size: "sm", type: "button", variant: "outline", children: resetLabel || t('Reset') }))] }));
15
15
  }
@@ -3,11 +3,11 @@ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useMemo } from 'react';
4
4
  import { QueryClientProvider } from '@tanstack/react-query';
5
5
  import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
6
- import { environment } from '../utils/environment.js';
6
+ import { isProductionEnvironment } from '../utils/environment.js';
7
7
  import { createQueryClient } from '../utils/query-client.js';
8
8
 
9
9
  const globalQueryClient = createQueryClient();
10
- function ReactQueryContainer({ children, enableDevTools = environment !== 'production', queryClient: _queryClient, }) {
10
+ function ReactQueryContainer({ children, enableDevTools = !isProductionEnvironment, queryClient: _queryClient, }) {
11
11
  const queryClient = useMemo(() => _queryClient || createQueryClient(), [_queryClient]);
12
12
  return (jsxs(QueryClientProvider, { client: queryClient, children: [enableDevTools && jsx(ReactQueryDevtools, { initialIsOpen: false }), children instanceof Function ? children({ queryClient }) : children] }));
13
13
  }
@@ -1,3 +1,4 @@
1
- export declare const environments: readonly ["marketingLocal", "sandbox", "sandbox-reverse-proxy", "production", "local", "storybook", "next", "spire-production"];
1
+ export declare const environments: readonly ["marketingLocal", "sandbox", "sandbox-reverse-proxy", "production", "local", "storybook", "next-production", "next-development"];
2
2
  export type Environment = (typeof environments)[number];
3
- export declare const environment: string;
3
+ export declare const environment: "marketingLocal" | "sandbox" | "sandbox-reverse-proxy" | "production" | "local" | "storybook" | "next-production" | "next-development";
4
+ export declare const isProductionEnvironment: boolean;
@@ -7,8 +7,8 @@ const environments = [
7
7
  'production',
8
8
  'local',
9
9
  'storybook',
10
- 'next',
11
- 'spire-production',
10
+ 'next-production',
11
+ 'next-development',
12
12
  ];
13
13
  const marketingLocal = /marketing.local.com/i;
14
14
  const storybookUrls = /localhost:6006|storybook.sonic.local.com/i;
@@ -16,11 +16,14 @@ const localUrls = /sonic.local.com/i;
16
16
  const reverseProxyUrls = /sonic-equipment.workers.dev/i;
17
17
  const sandboxUrls = /local|insitesandbox.com|azurestaticapps|ui.sonic-equipment.com|sandbox|accept|test/i;
18
18
  const productionUrls = /sonic-equipment.com|production/i;
19
- const spireProductionUrls = /spire.sonic-equipment.com/i;
20
19
  let environmentUrl;
21
20
  function getEnvironment() {
22
21
  if (typeof process !== 'undefined' && process.env.IS_NEXT === 'true') {
23
- return 'next';
22
+ if (process.env.ALGOLIA_APP_ID &&
23
+ process.env.ALGOLIA_APP_ID.includes('testing')) {
24
+ return 'next-development';
25
+ }
26
+ return 'next-production';
24
27
  }
25
28
  else if (typeof process !== 'undefined' && process.env.ISC_API_URL) {
26
29
  environmentUrl = process.env.ISC_API_URL;
@@ -51,9 +54,6 @@ function getEnvironment() {
51
54
  else if (sandboxUrls.test(environmentUrl)) {
52
55
  environment = 'sandbox';
53
56
  }
54
- else if (spireProductionUrls.test(environmentUrl)) {
55
- environment = 'spire-production';
56
- }
57
57
  else if (productionUrls.test(environmentUrl)) {
58
58
  environment = 'production';
59
59
  }
@@ -64,5 +64,6 @@ function getEnvironment() {
64
64
  return environment;
65
65
  }
66
66
  const environment = getEnvironment();
67
+ const isProductionEnvironment = environment.includes('production');
67
68
 
68
- export { environment, environments };
69
+ export { environment, environments, isProductionEnvironment };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "243.0.0",
3
+ "version": "245.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {