};
} );
-// eslint-disable-next-line camelcase
export const useDeposits = ( {
paged,
per_page: perPage,
diff --git a/client/data/deposits/resolvers.js b/client/data/deposits/resolvers.js
index 70e9f2a6a6c..13cfca88ffb 100644
--- a/client/data/deposits/resolvers.js
+++ b/client/data/deposits/resolvers.js
@@ -86,7 +86,6 @@ export function* getAllDepositsOverviews() {
}
}
-/*eslint-disable camelcase*/
const formatQueryFilters = ( query ) => ( {
match: query.match,
store_currency_is: query.storeCurrencyIs,
@@ -99,7 +98,6 @@ const formatQueryFilters = ( query ) => ( {
status_is: query.statusIs,
status_is_not: query.statusIsNot,
} );
-/*eslint-enable camelcase*/
/**
* Retrieves a series of deposits from the deposits list API.
diff --git a/client/data/deposits/test/reducer.js b/client/data/deposits/test/reducer.js
index c8ad6b358ad..ae7d5dec714 100644
--- a/client/data/deposits/test/reducer.js
+++ b/client/data/deposits/test/reducer.js
@@ -1,5 +1,4 @@
/** @format */
-/* eslint-disable camelcase */
/**
* Internal dependencies
diff --git a/client/data/deposits/test/resolvers.js b/client/data/deposits/test/resolvers.js
index 47311be8c3e..6369cc77c7e 100644
--- a/client/data/deposits/test/resolvers.js
+++ b/client/data/deposits/test/resolvers.js
@@ -1,5 +1,4 @@
/** @format */
-/* eslint-disable camelcase */
/**
* External dependencies
diff --git a/client/data/deposits/test/selectors.js b/client/data/deposits/test/selectors.js
index 5b81176c56f..cd8613a0758 100644
--- a/client/data/deposits/test/selectors.js
+++ b/client/data/deposits/test/selectors.js
@@ -1,5 +1,4 @@
/** @format */
-/* eslint-disable camelcase */
/**
* External dependencies
diff --git a/client/data/disputes/hooks.js b/client/data/disputes/hooks.js
index 5cd88b4a4b7..f9b31f3ffb5 100644
--- a/client/data/disputes/hooks.js
+++ b/client/data/disputes/hooks.js
@@ -30,7 +30,6 @@ export const useDisputeEvidence = () => {
return { updateDispute };
};
-// eslint-disable-next-line camelcase
export const useDisputes = ( { paged, per_page: perPage } ) =>
useSelect(
( select ) => {
diff --git a/client/data/disputes/test/actions.js b/client/data/disputes/test/actions.js
index 2a5d876485d..c02bf7f7885 100644
--- a/client/data/disputes/test/actions.js
+++ b/client/data/disputes/test/actions.js
@@ -1,5 +1,4 @@
/** @format */
-/* eslint-disable camelcase */
/**
* External dependencies
diff --git a/client/data/disputes/test/reducer.js b/client/data/disputes/test/reducer.js
index df57dc3be8f..aacc91f6a80 100644
--- a/client/data/disputes/test/reducer.js
+++ b/client/data/disputes/test/reducer.js
@@ -1,5 +1,4 @@
/** @format */
-/* eslint-disable camelcase */
/**
* Internal dependencies
diff --git a/client/data/disputes/test/resolvers.js b/client/data/disputes/test/resolvers.js
index 55080b6b1bd..fd476a5969b 100644
--- a/client/data/disputes/test/resolvers.js
+++ b/client/data/disputes/test/resolvers.js
@@ -1,5 +1,4 @@
/** @format */
-/* eslint-disable camelcase */
/**
* External dependencies
diff --git a/client/data/disputes/test/selectors.js b/client/data/disputes/test/selectors.js
index 3dad421f3ef..e413ef2a4e1 100644
--- a/client/data/disputes/test/selectors.js
+++ b/client/data/disputes/test/selectors.js
@@ -1,5 +1,4 @@
/** @format */
-/* eslint-disable camelcase */
/**
* Internal dependencies
diff --git a/client/data/index.js b/client/data/index.ts
similarity index 88%
rename from client/data/index.js
rename to client/data/index.ts
index ac1e3ef3871..5e78ebeccf1 100644
--- a/client/data/index.js
+++ b/client/data/index.ts
@@ -8,6 +8,7 @@ import { initStore } from './store';
initStore();
+// eslint-disable-next-line @typescript-eslint/naming-convention
export const WCPAY_STORE_NAME = STORE_NAME;
// We only ask for hooks when importing directly from 'data'.
diff --git a/client/data/settings/actions.js b/client/data/settings/actions.js
index 72ea26862ca..b6ca33b91b5 100644
--- a/client/data/settings/actions.js
+++ b/client/data/settings/actions.js
@@ -20,19 +20,16 @@ function updateSettingsValues( payload ) {
};
}
-export function updateDigitalWalletsButtonType( type ) {
- // eslint-disable-next-line camelcase
- return updateSettingsValues( { digital_wallets_button_type: type } );
+export function updatePaymentRequestButtonType( type ) {
+ return updateSettingsValues( { payment_request_button_type: type } );
}
-export function updateDigitalWalletsButtonSize( size ) {
- // eslint-disable-next-line camelcase
- return updateSettingsValues( { digital_wallets_button_size: size } );
+export function updatePaymentRequestButtonSize( size ) {
+ return updateSettingsValues( { payment_request_button_size: size } );
}
-export function updateDigitalWalletsButtonTheme( theme ) {
- // eslint-disable-next-line camelcase
- return updateSettingsValues( { digital_wallets_button_theme: theme } );
+export function updatePaymentRequestButtonTheme( theme ) {
+ return updateSettingsValues( { payment_request_button_theme: theme } );
}
export function updateSettings( data ) {
@@ -43,57 +40,51 @@ export function updateSettings( data ) {
}
export function updateIsWCPayEnabled( isEnabled ) {
- // eslint-disable-next-line camelcase
return updateSettingsValues( { is_wcpay_enabled: isEnabled } );
}
-export function updateIsDigitalWalletsEnabled( isEnabled ) {
- // eslint-disable-next-line camelcase
- return updateSettingsValues( { is_digital_wallets_enabled: isEnabled } );
+export function updateIsPaymentRequestEnabled( isEnabled ) {
+ return updateSettingsValues( { is_payment_request_enabled: isEnabled } );
}
export function updateEnabledPaymentMethodIds( methodIds ) {
return updateSettingsValues( {
- // eslint-disable-next-line camelcase
enabled_payment_method_ids: [ ...methodIds ],
} );
}
-export function updateIsSavingSettings( isSaving ) {
+export function updateIsSavingSettings( isSaving, error ) {
return {
type: ACTION_TYPES.SET_IS_SAVING_SETTINGS,
isSaving,
+ error,
};
}
export function updateIsManualCaptureEnabled( isEnabled ) {
- // eslint-disable-next-line camelcase
return updateSettingsValues( { is_manual_capture_enabled: isEnabled } );
}
export function updateIsTestModeEnabled( isEnabled ) {
- // eslint-disable-next-line camelcase
return updateSettingsValues( { is_test_mode_enabled: isEnabled } );
}
export function updateIsDebugLogEnabled( isEnabled ) {
- // eslint-disable-next-line camelcase
return updateSettingsValues( { is_debug_log_enabled: isEnabled } );
}
export function updateAccountStatementDescriptor( accountStatementDescriptor ) {
return updateSettingsValues( {
- // eslint-disable-next-line camelcase
account_statement_descriptor: accountStatementDescriptor,
} );
}
export function* saveSettings() {
- let isSuccess = false;
+ let error = null;
try {
const settings = select( STORE_NAME ).getSettings();
- yield updateIsSavingSettings( true );
+ yield updateIsSavingSettings( true, null );
yield apiFetch( {
path: `${ NAMESPACE }/settings`,
@@ -104,22 +95,20 @@ export function* saveSettings() {
yield dispatch( 'core/notices' ).createSuccessNotice(
__( 'Settings saved.', 'woocommerce-payments' )
);
-
- isSuccess = true;
} catch ( e ) {
+ error = e;
yield dispatch( 'core/notices' ).createErrorNotice(
__( 'Error saving settings.', 'woocommerce-payments' )
);
} finally {
- yield updateIsSavingSettings( false );
+ yield updateIsSavingSettings( false, error );
}
- return isSuccess;
+ return null === error;
}
-export function updateDigitalWalletsLocations( locations ) {
+export function updatePaymentRequestLocations( locations ) {
return updateSettingsValues( {
- // eslint-disable-next-line camelcase
- digital_wallets_enabled_locations: [ ...locations ],
+ payment_request_enabled_locations: [ ...locations ],
} );
}
diff --git a/client/data/settings/hooks.js b/client/data/settings/hooks.js
index 75417e639b1..de301f3c407 100644
--- a/client/data/settings/hooks.js
+++ b/client/data/settings/hooks.js
@@ -139,61 +139,69 @@ export const useSettings = () => {
);
};
-export const useDigitalWalletsEnabledSettings = () => {
- const { updateIsDigitalWalletsEnabled } = useDispatch( STORE_NAME );
+export const usePaymentRequestEnabledSettings = () => {
+ const { updateIsPaymentRequestEnabled } = useDispatch( STORE_NAME );
return useSelect( ( select ) => {
- const { getIsDigitalWalletsEnabled } = select( STORE_NAME );
+ const { getIsPaymentRequestEnabled } = select( STORE_NAME );
- return [ getIsDigitalWalletsEnabled(), updateIsDigitalWalletsEnabled ];
+ return [ getIsPaymentRequestEnabled(), updateIsPaymentRequestEnabled ];
} );
};
-export const useDigitalWalletsLocations = () => {
- const { updateDigitalWalletsLocations } = useDispatch( STORE_NAME );
+export const usePaymentRequestLocations = () => {
+ const { updatePaymentRequestLocations } = useDispatch( STORE_NAME );
return useSelect( ( select ) => {
- const { getDigitalWalletsLocations } = select( STORE_NAME );
+ const { getPaymentRequestLocations } = select( STORE_NAME );
- return [ getDigitalWalletsLocations(), updateDigitalWalletsLocations ];
+ return [ getPaymentRequestLocations(), updatePaymentRequestLocations ];
} );
};
-export const useDigitalWalletsButtonType = () => {
- const { updateDigitalWalletsButtonType } = useDispatch( STORE_NAME );
+export const usePaymentRequestButtonType = () => {
+ const { updatePaymentRequestButtonType } = useDispatch( STORE_NAME );
return useSelect( ( select ) => {
- const { getDigitalWalletsButtonType } = select( STORE_NAME );
+ const { getPaymentRequestButtonType } = select( STORE_NAME );
return [
- getDigitalWalletsButtonType(),
- updateDigitalWalletsButtonType,
+ getPaymentRequestButtonType(),
+ updatePaymentRequestButtonType,
];
} );
};
-export const useDigitalWalletsButtonSize = () => {
- const { updateDigitalWalletsButtonSize } = useDispatch( STORE_NAME );
+export const usePaymentRequestButtonSize = () => {
+ const { updatePaymentRequestButtonSize } = useDispatch( STORE_NAME );
return useSelect( ( select ) => {
- const { getDigitalWalletsButtonSize } = select( STORE_NAME );
+ const { getPaymentRequestButtonSize } = select( STORE_NAME );
return [
- getDigitalWalletsButtonSize(),
- updateDigitalWalletsButtonSize,
+ getPaymentRequestButtonSize(),
+ updatePaymentRequestButtonSize,
];
} );
};
-export const useDigitalWalletsButtonTheme = () => {
- const { updateDigitalWalletsButtonTheme } = useDispatch( STORE_NAME );
+export const usePaymentRequestButtonTheme = () => {
+ const { updatePaymentRequestButtonTheme } = useDispatch( STORE_NAME );
return useSelect( ( select ) => {
- const { getDigitalWalletsButtonTheme } = select( STORE_NAME );
+ const { getPaymentRequestButtonTheme } = select( STORE_NAME );
return [
- getDigitalWalletsButtonTheme(),
- updateDigitalWalletsButtonTheme,
+ getPaymentRequestButtonTheme(),
+ updatePaymentRequestButtonTheme,
];
} );
};
+
+export const useGetSavingError = () => {
+ return useSelect( ( select ) => {
+ const { getSavingError } = select( STORE_NAME );
+
+ return getSavingError();
+ }, [] );
+};
diff --git a/client/data/settings/reducer.js b/client/data/settings/reducer.js
index 4bbe274b527..44ad8f1bfc3 100644
--- a/client/data/settings/reducer.js
+++ b/client/data/settings/reducer.js
@@ -7,6 +7,7 @@ import ACTION_TYPES from './action-types';
const defaultState = {
isSaving: false,
+ savingError: null,
data: {},
};
@@ -24,6 +25,7 @@ export const receiveSettings = (
case ACTION_TYPES.SET_SETTINGS_VALUES:
return {
...state,
+ savingError: null,
data: {
...state.data,
...action.payload,
@@ -34,6 +36,7 @@ export const receiveSettings = (
return {
...state,
isSaving: action.isSaving,
+ savingError: action.error,
};
}
diff --git a/client/data/settings/selectors.js b/client/data/settings/selectors.js
index c124e94609d..71866e471d6 100644
--- a/client/data/settings/selectors.js
+++ b/client/data/settings/selectors.js
@@ -47,26 +47,30 @@ export const getIsDevModeEnabled = ( state ) => {
return getSettings( state ).is_dev_mode_enabled || false;
};
-export const getIsDigitalWalletsEnabled = ( state ) => {
- return getSettings( state ).is_digital_wallets_enabled || false;
+export const getIsPaymentRequestEnabled = ( state ) => {
+ return getSettings( state ).is_payment_request_enabled || false;
};
export const getIsDebugLogEnabled = ( state ) => {
return getSettings( state ).is_debug_log_enabled || false;
};
-export const getDigitalWalletsLocations = ( state ) => {
- return getSettings( state ).digital_wallets_enabled_locations || EMPTY_ARR;
+export const getPaymentRequestLocations = ( state ) => {
+ return getSettings( state ).payment_request_enabled_locations || EMPTY_ARR;
};
-export const getDigitalWalletsButtonType = ( state ) => {
- return getSettings( state ).digital_wallets_button_type || '';
+export const getPaymentRequestButtonType = ( state ) => {
+ return getSettings( state ).payment_request_button_type || '';
};
-export const getDigitalWalletsButtonSize = ( state ) => {
- return getSettings( state ).digital_wallets_button_size || '';
+export const getPaymentRequestButtonSize = ( state ) => {
+ return getSettings( state ).payment_request_button_size || '';
};
-export const getDigitalWalletsButtonTheme = ( state ) => {
- return getSettings( state ).digital_wallets_button_theme || '';
+export const getPaymentRequestButtonTheme = ( state ) => {
+ return getSettings( state ).payment_request_button_theme || '';
+};
+
+export const getSavingError = ( state ) => {
+ return getSettingsState( state ).savingError;
};
diff --git a/client/data/settings/test/actions.js b/client/data/settings/test/actions.js
index 55d35bb81da..64fef5f1f18 100644
--- a/client/data/settings/test/actions.js
+++ b/client/data/settings/test/actions.js
@@ -36,10 +36,8 @@ describe( 'Settings actions tests', () => {
test( 'makes POST request with settings', () => {
const settingsMock = {
- /* eslint-disable camelcase */
enabled_payment_method_ids: [ 'foo', 'bar' ],
is_wcpay_enabled: true,
- /* eslint-enable camelcase */
};
select.mockReturnValue( {
@@ -67,12 +65,12 @@ describe( 'Settings actions tests', () => {
const isSavingStartIndex = findIndex(
yielded,
- updateIsSavingSettings( true )
+ updateIsSavingSettings( true, null )
);
const isSavingEndIndex = findIndex(
yielded,
- updateIsSavingSettings( false )
+ updateIsSavingSettings( false, null )
);
expect( apiRequestIndex ).not.toEqual( -1 );
@@ -119,7 +117,14 @@ describe( 'Settings actions tests', () => {
expect(
dispatch( 'core/notices' ).createErrorNotice
).toHaveBeenCalled();
- expect( yielded ).toContainEqual( updateIsSavingSettings( false ) );
+ expect( yielded ).toEqual(
+ expect.arrayContaining( [
+ expect.objectContaining( {
+ type: 'SET_IS_SAVING_SETTINGS',
+ isSaving: false,
+ } ),
+ ] )
+ );
} );
} );
} );
diff --git a/client/data/settings/test/hooks.js b/client/data/settings/test/hooks.js
index 3c7ef01d187..5570cc7b21f 100644
--- a/client/data/settings/test/hooks.js
+++ b/client/data/settings/test/hooks.js
@@ -13,8 +13,8 @@ import {
useManualCapture,
useSettings,
useTestMode,
- useDigitalWalletsEnabledSettings,
- useDigitalWalletsLocations,
+ usePaymentRequestEnabledSettings,
+ usePaymentRequestLocations,
} from '../hooks';
import { STORE_NAME } from '../../constants';
@@ -212,55 +212,55 @@ describe( 'Settings hooks tests', () => {
);
} );
- describe( 'useDigitalWalletsEnabledSettings()', () => {
- test( 'returns digital wallets settings from selector', () => {
+ describe( 'usePaymentRequestEnabledSettings()', () => {
+ test( 'returns payment request settings from selector', () => {
actions = {
- updateIsDigitalWalletsEnabled: jest.fn(),
+ updateIsPaymentRequestEnabled: jest.fn(),
};
selectors = {
- getIsDigitalWalletsEnabled: jest.fn( () => true ),
+ getIsPaymentRequestEnabled: jest.fn( () => true ),
};
const [
- isDigitalWalletsEnabled,
- updateIsDigitalWalletsEnabled,
- ] = useDigitalWalletsEnabledSettings();
+ isPaymentRequestEnabled,
+ updateIsPaymentRequestEnabled,
+ ] = usePaymentRequestEnabledSettings();
- updateIsDigitalWalletsEnabled( false );
+ updateIsPaymentRequestEnabled( false );
- expect( isDigitalWalletsEnabled ).toEqual( true );
+ expect( isPaymentRequestEnabled ).toEqual( true );
expect(
- actions.updateIsDigitalWalletsEnabled
+ actions.updateIsPaymentRequestEnabled
).toHaveBeenCalledWith( false );
} );
} );
- describe( 'useDigitalWalletsLocations()', () => {
- test( 'returns and updates digital wallets locations', () => {
+ describe( 'usePaymentRequestLocations()', () => {
+ test( 'returns and updates payment request locations', () => {
const locationsBeforeUpdate = [];
const locationsAfterUpdate = [ 'cart' ];
actions = {
- updateDigitalWalletsLocations: jest.fn(),
+ updatePaymentRequestLocations: jest.fn(),
};
selectors = {
- getDigitalWalletsLocations: jest.fn(
+ getPaymentRequestLocations: jest.fn(
() => locationsBeforeUpdate
),
};
const [
- digitalWalletsLocations,
- updateDigitalWalletsLocations,
- ] = useDigitalWalletsLocations();
+ paymentRequestLocations,
+ updatePaymentRequestLocations,
+ ] = usePaymentRequestLocations();
- updateDigitalWalletsLocations( locationsAfterUpdate );
+ updatePaymentRequestLocations( locationsAfterUpdate );
- expect( digitalWalletsLocations ).toEqual( locationsBeforeUpdate );
+ expect( paymentRequestLocations ).toEqual( locationsBeforeUpdate );
expect(
- actions.updateDigitalWalletsLocations
+ actions.updatePaymentRequestLocations
).toHaveBeenCalledWith( locationsAfterUpdate );
} );
} );
diff --git a/client/data/settings/test/reducer.js b/client/data/settings/test/reducer.js
index 740746c4374..13ac8fdfcfa 100644
--- a/client/data/settings/test/reducer.js
+++ b/client/data/settings/test/reducer.js
@@ -9,8 +9,8 @@ import {
updateIsSavingSettings,
updateIsManualCaptureEnabled,
updateAccountStatementDescriptor,
- updateDigitalWalletsLocations,
- updateIsDigitalWalletsEnabled,
+ updatePaymentRequestLocations,
+ updateIsPaymentRequestEnabled,
} from '../actions';
describe( 'Settings reducer tests', () => {
@@ -20,6 +20,7 @@ describe( 'Settings reducer tests', () => {
expect( defaultState ).toEqual( {
isSaving: false,
data: {},
+ savingError: null,
} );
} );
@@ -56,6 +57,7 @@ describe( 'Settings reducer tests', () => {
data: {
baz: 'quux',
},
+ savingError: {},
};
const newSettings = {
@@ -69,6 +71,7 @@ describe( 'Settings reducer tests', () => {
data: {
quuz: 'corge',
},
+ savingError: {},
} );
} );
} );
@@ -77,23 +80,33 @@ describe( 'Settings reducer tests', () => {
test( 'toggles isSaving', () => {
const oldState = {
isSaving: false,
+ savingError: null,
};
- const state = reducer( oldState, updateIsSavingSettings( true ) );
+ const state = reducer(
+ oldState,
+ updateIsSavingSettings( true, {} )
+ );
expect( state.isSaving ).toBeTruthy();
+ expect( state.savingError ).toEqual( {} );
} );
test( 'leaves other fields unchanged', () => {
const oldState = {
foo: 'bar',
isSaving: false,
+ savingError: {},
};
- const state = reducer( oldState, updateIsSavingSettings( true ) );
+ const state = reducer(
+ oldState,
+ updateIsSavingSettings( true, null )
+ );
expect( state ).toEqual( {
foo: 'bar',
+ savingError: null,
isSaving: true,
} );
} );
@@ -103,8 +116,9 @@ describe( 'Settings reducer tests', () => {
test( 'sets `data.enabled_payment_method_ids`', () => {
const oldState = {
data: {
- enabled_payment_method_ids: [], // eslint-disable-line
+ enabled_payment_method_ids: [],
},
+ savingError: null,
};
const methodIds = [ 'foo', 'bar' ];
@@ -123,9 +137,10 @@ describe( 'Settings reducer tests', () => {
const oldState = {
baz: 'quux',
data: {
- enabled_payment_method_ids: [], // eslint-disable-line
+ enabled_payment_method_ids: [],
quuz: 'corge',
},
+ savingError: {},
};
const methodIds = [ 'foo', 'bar' ];
@@ -138,9 +153,10 @@ describe( 'Settings reducer tests', () => {
expect( state ).toEqual( {
baz: 'quux',
data: {
- enabled_payment_method_ids: methodIds, // eslint-disable-line
+ enabled_payment_method_ids: methodIds,
quuz: 'corge',
},
+ savingError: null,
} );
} );
} );
@@ -149,7 +165,7 @@ describe( 'Settings reducer tests', () => {
test( 'toggles `data.is_wcpay_enabled`', () => {
const oldState = {
data: {
- is_wcpay_enabled: false, // eslint-disable-line
+ is_wcpay_enabled: false,
},
};
@@ -162,9 +178,10 @@ describe( 'Settings reducer tests', () => {
const oldState = {
foo: 'bar',
data: {
- is_wcpay_enabled: false, // eslint-disable-line
+ is_wcpay_enabled: false,
baz: 'quux',
},
+ savingError: {},
};
const state = reducer( oldState, updateIsWCPayEnabled( true ) );
@@ -172,9 +189,10 @@ describe( 'Settings reducer tests', () => {
expect( state ).toEqual( {
foo: 'bar',
data: {
- is_wcpay_enabled: true, // eslint-disable-line
+ is_wcpay_enabled: true,
baz: 'quux',
},
+ savingError: null,
} );
} );
} );
@@ -183,7 +201,7 @@ describe( 'Settings reducer tests', () => {
test( 'toggles `data.is_manual_capture_enabled`', () => {
const oldState = {
data: {
- is_manual_capture_enabled: false, // eslint-disable-line
+ is_manual_capture_enabled: false,
},
};
@@ -199,9 +217,10 @@ describe( 'Settings reducer tests', () => {
const oldState = {
foo: 'bar',
data: {
- is_manual_capture_enabled: false, // eslint-disable-line
+ is_manual_capture_enabled: false,
baz: 'quux',
},
+ savingError: {},
};
const state = reducer(
@@ -210,9 +229,10 @@ describe( 'Settings reducer tests', () => {
);
expect( state ).toEqual( {
+ savingError: null,
foo: 'bar',
data: {
- is_manual_capture_enabled: true, // eslint-disable-line
+ is_manual_capture_enabled: true,
baz: 'quux',
},
} );
@@ -223,7 +243,7 @@ describe( 'Settings reducer tests', () => {
test( 'toggles `data.account_statement_descriptor`', () => {
const oldState = {
data: {
- account_statement_descriptor: 'Statement', // eslint-disable-line
+ account_statement_descriptor: 'Statement',
},
};
@@ -241,9 +261,10 @@ describe( 'Settings reducer tests', () => {
const oldState = {
foo: 'bar',
data: {
- account_statement_descriptor: 'Statement', // eslint-disable-line
+ account_statement_descriptor: 'Statement',
baz: 'quux',
},
+ savingError: {},
};
const state = reducer(
@@ -253,76 +274,76 @@ describe( 'Settings reducer tests', () => {
expect( state ).toEqual( {
foo: 'bar',
+ savingError: null,
data: {
- account_statement_descriptor: 'New Statement', // eslint-disable-line
+ account_statement_descriptor: 'New Statement',
baz: 'quux',
},
} );
} );
} );
- describe( 'SET_IS_DIGITAL_WALLETS_ENABLED', () => {
- test( 'toggles `data.is_digital_wallets_enabled`', () => {
+ describe( 'SET_IS_PAYMENT_REQUEST_ENABLED', () => {
+ test( 'toggles `data.is_payment_request_enabled`', () => {
const oldState = {
data: {
- // eslint-disable-next-line camelcase
- is_digital_wallets_enabled: false,
+ is_payment_request_enabled: false,
},
+ savingError: null,
};
const state = reducer(
oldState,
- updateIsDigitalWalletsEnabled( true )
+ updateIsPaymentRequestEnabled( true )
);
- expect( state.data.is_digital_wallets_enabled ).toBeTruthy();
+ expect( state.data.is_payment_request_enabled ).toBeTruthy();
} );
test( 'leaves other fields unchanged', () => {
const oldState = {
foo: 'bar',
data: {
- // eslint-disable-next-line camelcase
- is_digital_wallets_enabled: false,
+ is_payment_request_enabled: false,
baz: 'quux',
},
+ savingError: {},
};
const state = reducer(
oldState,
- updateIsDigitalWalletsEnabled( true )
+ updateIsPaymentRequestEnabled( true )
);
expect( state ).toEqual( {
foo: 'bar',
+ savingError: null,
data: {
- // eslint-disable-next-line camelcase
- is_digital_wallets_enabled: true,
+ is_payment_request_enabled: true,
baz: 'quux',
},
} );
} );
} );
- describe( 'SET_DIGITAL_WALLETS_LOCATIONS', () => {
- const initDigitalWalletsState = [ 'product' ];
- const enableAlldigitalWalletsState = [ 'product', 'checkout', 'cart' ];
+ describe( 'SET_PAYMENT_REQUEST_LOCATIONS', () => {
+ const initPaymentRequestState = [ 'product' ];
+ const enableAllpaymentRequestState = [ 'product', 'checkout', 'cart' ];
- test( 'toggle `data.digital_wallets_enabled_locations`', () => {
+ test( 'toggle `data.payment_request_enabled_locations`', () => {
const oldState = {
data: {
- // eslint-disable-next-line camelcase
- digital_wallets_enabled_locations: initDigitalWalletsState,
+ payment_request_enabled_locations: initPaymentRequestState,
},
};
const state = reducer(
oldState,
- updateDigitalWalletsLocations( enableAlldigitalWalletsState )
+ updatePaymentRequestLocations( enableAllpaymentRequestState )
);
- expect( state.data.digital_wallets_enabled_locations ).toEqual(
- enableAlldigitalWalletsState
+ expect( state.data.payment_request_enabled_locations ).toEqual(
+ enableAllpaymentRequestState
);
} );
@@ -330,24 +351,24 @@ describe( 'Settings reducer tests', () => {
const oldState = {
foo: 'bar',
data: {
- // eslint-disable-next-line camelcase
- digital_wallets_enabled_locations: initDigitalWalletsState,
+ payment_request_enabled_locations: initPaymentRequestState,
baz: 'quux',
},
+ savingError: {},
};
const state = reducer(
oldState,
- updateDigitalWalletsLocations( enableAlldigitalWalletsState )
+ updatePaymentRequestLocations( enableAllpaymentRequestState )
);
expect( state ).toEqual( {
foo: 'bar',
data: {
- // eslint-disable-next-line camelcase
- digital_wallets_enabled_locations: enableAlldigitalWalletsState,
+ payment_request_enabled_locations: enableAllpaymentRequestState,
baz: 'quux',
},
+ savingError: null,
} );
} );
} );
diff --git a/client/data/settings/test/selectors.js b/client/data/settings/test/selectors.js
index 2f1f73550ce..ad4e2d70c33 100644
--- a/client/data/settings/test/selectors.js
+++ b/client/data/settings/test/selectors.js
@@ -8,8 +8,8 @@ import {
getIsManualCaptureEnabled,
getAccountStatementDescriptor,
isSavingSettings,
- getDigitalWalletsLocations,
- getIsDigitalWalletsEnabled,
+ getPaymentRequestLocations,
+ getIsPaymentRequestEnabled,
} from '../selectors';
describe( 'Settings selectors tests', () => {
@@ -39,7 +39,6 @@ describe( 'Settings selectors tests', () => {
const state = {
settings: {
data: {
- // eslint-disable-next-line camelcase
is_wcpay_enabled: true,
},
},
@@ -63,7 +62,6 @@ describe( 'Settings selectors tests', () => {
const state = {
settings: {
data: {
- // eslint-disable-next-line camelcase
enabled_payment_method_ids: [ 'foo', 'bar' ],
},
},
@@ -109,7 +107,6 @@ describe( 'Settings selectors tests', () => {
const state = {
settings: {
data: {
- // eslint-disable-next-line camelcase
is_manual_capture_enabled: true,
},
},
@@ -133,7 +130,6 @@ describe( 'Settings selectors tests', () => {
const state = {
settings: {
data: {
- // eslint-disable-next-line camelcase
account_statement_descriptor: 'my account statement',
},
},
@@ -154,18 +150,17 @@ describe( 'Settings selectors tests', () => {
} );
} );
- describe( 'getIsDigitalWalletsEnabled()', () => {
- test( 'returns the value of state.settings.data.is_digital_wallets_enabled', () => {
+ describe( 'getIsPaymentRequestEnabled()', () => {
+ test( 'returns the value of state.settings.data.is_payment_request_enabled', () => {
const state = {
settings: {
data: {
- // eslint-disable-next-line camelcase
- is_digital_wallets_enabled: true,
+ is_payment_request_enabled: true,
},
},
};
- expect( getIsDigitalWalletsEnabled( state ) ).toBeTruthy();
+ expect( getIsPaymentRequestEnabled( state ) ).toBeTruthy();
} );
test.each( [
@@ -174,17 +169,16 @@ describe( 'Settings selectors tests', () => {
[ { settings: {} } ],
[ { settings: { data: {} } } ],
] )( 'returns false if missing (tested state: %j)', ( state ) => {
- expect( getIsDigitalWalletsEnabled( state ) ).toBeFalsy();
+ expect( getIsPaymentRequestEnabled( state ) ).toBeFalsy();
} );
} );
- describe( 'getDigitalWalletsLocations()', () => {
- test( 'returns the value of state.settings.data.digital_wallets_enabled_locations', () => {
+ describe( 'getPaymentRequestLocations()', () => {
+ test( 'returns the value of state.settings.data.payment_request_enabled_locations', () => {
const state = {
settings: {
data: {
- // eslint-disable-next-line camelcase
- digital_wallets_enabled_locations: [
+ payment_request_enabled_locations: [
'product',
'cart',
],
@@ -192,7 +186,7 @@ describe( 'Settings selectors tests', () => {
},
};
- expect( getDigitalWalletsLocations( state ) ).toEqual( [
+ expect( getPaymentRequestLocations( state ) ).toEqual( [
'product',
'cart',
] );
@@ -204,7 +198,7 @@ describe( 'Settings selectors tests', () => {
[ { settings: {} } ],
[ { settings: { data: {} } } ],
] )( 'returns [] if missing (tested state: %j)', ( state ) => {
- expect( getDigitalWalletsLocations( state ) ).toEqual( [] );
+ expect( getPaymentRequestLocations( state ) ).toEqual( [] );
} );
} );
} );
diff --git a/client/data/transactions/hooks.js b/client/data/transactions/hooks.ts
similarity index 64%
rename from client/data/transactions/hooks.js
rename to client/data/transactions/hooks.ts
index 9b952b020d2..ac8a6651844 100644
--- a/client/data/transactions/hooks.js
+++ b/client/data/transactions/hooks.ts
@@ -4,12 +4,57 @@
*/
import { useSelect } from '@wordpress/data';
import moment from 'moment';
+import type { Query } from '@woocommerce/navigation';
/**
* Internal dependencies
*/
import { STORE_NAME } from '../constants';
+// TODO: refine this type with more detailed information.
+export interface Transaction {
+ amount: number;
+ order: {
+ subscriptions?: { number: number; url: string }[];
+ url?: string;
+ customer_url?: string;
+ number?: number;
+ };
+ charge_id: string;
+ fees: number;
+ net: number;
+ risk_level: number;
+ customer_amount: number;
+ customer_name: string;
+ customer_email: string;
+ customer_country: string;
+ customer_currency: string;
+ deposit_id?: string;
+ available_on: string;
+ currency: string;
+ transaction_id: string;
+ date: string;
+ type: 'charge' | 'refund';
+ source: string;
+}
+
+interface Transactions {
+ transactions: Transaction[];
+ transactionsError: unknown;
+ isLoading: boolean;
+}
+interface TransactionsSummary {
+ transactionsSummary: {
+ count?: number;
+ total?: number;
+ fees?: number;
+ net?: number;
+ currency?: string;
+ store_currencies?: string[];
+ };
+ isLoading: boolean;
+}
+
export const useTransactions = (
{
paged,
@@ -24,9 +69,9 @@ export const useTransactions = (
type_is_not: typeIsNot,
store_currency_is: storeCurrencyIs,
search,
- },
- depositId
-) =>
+ }: Query,
+ depositId: string
+): Transactions =>
useSelect(
( select ) => {
const {
@@ -36,8 +81,10 @@ export const useTransactions = (
} = select( STORE_NAME );
const query = {
- paged: Number.isNaN( parseInt( paged, 10 ) ) ? '1' : paged,
- perPage: Number.isNaN( parseInt( perPage, 10 ) )
+ paged: Number.isNaN( parseInt( paged ?? '', 10 ) )
+ ? '1'
+ : paged,
+ perPage: Number.isNaN( parseInt( perPage ?? '', 10 ) )
? '25'
: perPage,
orderby: orderby || 'date',
@@ -90,9 +137,9 @@ export const useTransactionsSummary = (
type_is_not: typeIsNot,
store_currency_is: storeCurrencyIs,
search,
- },
- depositId
-) =>
+ }: Query,
+ depositId: string
+): TransactionsSummary =>
useSelect(
( select ) => {
const { getTransactionsSummary, isResolving } = select(
diff --git a/client/data/transactions/resolvers.js b/client/data/transactions/resolvers.js
index 645d110b1ac..dc4489466c1 100644
--- a/client/data/transactions/resolvers.js
+++ b/client/data/transactions/resolvers.js
@@ -18,7 +18,6 @@ import {
} from './actions';
import { formatDateValue } from 'utils';
-/*eslint-disable camelcase*/
const formatQueryFilters = ( query ) => ( {
match: query.match,
date_before: formatDateValue( query.dateBefore, true ),
@@ -33,7 +32,6 @@ const formatQueryFilters = ( query ) => ( {
deposit_id: query.depositId,
search: query.search,
} );
-/*eslint-enable camelcase*/
/**
* Retrieves a series of transactions from the transactions list API.
diff --git a/client/deposits/details/test/index.js b/client/deposits/details/test/index.js
index d6f1b34cd7d..090010ceabe 100644
--- a/client/deposits/details/test/index.js
+++ b/client/deposits/details/test/index.js
@@ -24,7 +24,7 @@ const mockDeposit = {
bankAccount: 'MOCK BANK •••• 1234 (USD)',
automatic: true,
fee: 30,
- fee_percetange: 1.5, // eslint-disable-line camelcase
+ fee_percetange: 1.5,
};
describe( 'Deposit overview', () => {
diff --git a/client/deposits/index.js b/client/deposits/index.js
index dfd3b1adb11..2d78560b9d2 100644
--- a/client/deposits/index.js
+++ b/client/deposits/index.js
@@ -13,16 +13,16 @@ import DepositsList from './list';
import {
EmptyStateList,
EmptyStateTableHeaders,
-} from '../emtpy-state-table/list';
-import EmptyStateTable from 'emtpy-state-table';
-import ListBanner from '../emtpy-state-table/deposits-banner.svg';
+} from '../empty-state-table/list';
+import EmptyStateTable from 'empty-state-table';
+import ListBanner from '../empty-state-table/deposits-banner.svg';
import { Experiment } from '@woocommerce/explat';
const DepositsPage = () => {
return (
{
depositsSummary: {
count: 2,
total: 5000,
- // eslint-disable-next-line camelcase
store_currencies: [ 'usd', 'eur' ],
},
isLoading: false,
diff --git a/client/deposits/strings.js b/client/deposits/strings.js
index 79ff483647a..a2ea34690aa 100644
--- a/client/deposits/strings.js
+++ b/client/deposits/strings.js
@@ -13,7 +13,6 @@ export const displayType = {
export const displayStatus = {
paid: __( 'Paid', 'woocommerce-payments' ),
pending: __( 'Pending', 'woocommerce-payments' ),
- // eslint-disable-next-line camelcase
in_transit: __( 'In transit', 'woocommerce-payments' ),
canceled: __( 'Canceled', 'woocommerce-payments' ),
failed: __( 'Failed', 'woocommerce-payments' ),
diff --git a/client/deposits/utils/test/index.js b/client/deposits/utils/test/index.js
index 0dbd19f63e8..045c86042a2 100644
--- a/client/deposits/utils/test/index.js
+++ b/client/deposits/utils/test/index.js
@@ -19,8 +19,7 @@ function getDepositSchedule(
includeLastDeposit = true,
disabled = false
) {
- /* eslint-disable camelcase */
- const last_deposit = {
+ const lastDeposit = {
id: 'last_deposit',
amount: 6574,
date: new Date( '2019-04-18' ).getTime(),
@@ -31,9 +30,8 @@ function getDepositSchedule(
deposits_schedule: schedule,
deposits_disabled: disabled,
},
- last_deposit: includeLastDeposit ? last_deposit : null,
+ last_deposit: includeLastDeposit ? lastDeposit : null,
} );
- /* eslint-enable camelcase */
if ( 'string' === typeof descriptor ) {
return descriptor;
@@ -70,7 +68,6 @@ describe( 'Deposits Overview Utils / getDepositScheduleDescriptor', () => {
test( 'renders deposit schedule for weekly interval', () => {
const depositSchedule = getDepositSchedule( {
interval: 'weekly',
- // eslint-disable-next-line camelcase
weekly_anchor: 'monday',
} );
expect( depositSchedule ).toEqual( 'Automatic, every week on Monday' );
@@ -79,7 +76,6 @@ describe( 'Deposits Overview Utils / getDepositScheduleDescriptor', () => {
test( 'renders deposit schedule for monthly interval', () => {
const depositSchedule = getDepositSchedule( {
interval: 'monthly',
- // eslint-disable-next-line camelcase
monthly_anchor: 26,
} );
expect( depositSchedule ).toEqual(
@@ -91,7 +87,6 @@ describe( 'Deposits Overview Utils / getDepositScheduleDescriptor', () => {
momentLib.locale( 'de' );
const depositSchedule = getDepositSchedule( {
interval: 'weekly',
- // eslint-disable-next-line camelcase
weekly_anchor: 'tuesday',
} );
// without resetting the locale to en the anchor monday would become Sonntag, instead of Dienstag
@@ -126,13 +121,11 @@ describe( 'Deposits Overview Utils / getDepositDate', () => {
describe( 'Deposits Overview Utils / getBalanceDepositCount', () => {
test( 'formats the count with a single deposit', () => {
- // eslint-disable-next-line camelcase
const balance = { deposits_count: 1 };
expect( getBalanceDepositCount( balance ) ).toEqual( '1 deposit' );
} );
test( 'formats the count with multiple deposits', () => {
- // eslint-disable-next-line camelcase
const balance = { deposits_count: 3 };
expect( getBalanceDepositCount( balance ) ).toEqual( '3 deposits' );
} );
diff --git a/client/disputes/details/test/index.js b/client/disputes/details/test/index.js
index dd2d6f31836..b9e4bba3f92 100644
--- a/client/disputes/details/test/index.js
+++ b/client/disputes/details/test/index.js
@@ -44,9 +44,7 @@ describe( 'Dispute details screen', () => {
amount: 1000,
currency: 'usd',
created: 1572590800,
- // eslint-disable-next-line camelcase
evidence_details: {
- // eslint-disable-next-line camelcase
due_by: 1573199200,
},
reason,
diff --git a/client/disputes/evidence/index.js b/client/disputes/evidence/index.js
index e9e00ec5ae8..77397a5b1cc 100644
--- a/client/disputes/evidence/index.js
+++ b/client/disputes/evidence/index.js
@@ -510,7 +510,26 @@ export default ( { query } ) => {
We rely on WC-Admin Transient notices to display success message.
https://github.com/woocommerce/woocommerce-admin/tree/master/client/layout/transient-notices.
*/
- createSuccessNotice( message );
+ createSuccessNotice( message, {
+ actions: [
+ {
+ label: submit
+ ? __(
+ 'View submitted evidence',
+ 'woocommerce-payments'
+ )
+ : __(
+ 'Return to evidence submission',
+ 'woocommerce-payments'
+ ),
+ url: addQueryArgs( 'admin.php', {
+ page: 'wc-admin',
+ path: '/payments/disputes/challenge',
+ id: query.id,
+ } ),
+ },
+ ],
+ } );
getHistory().push( href );
};
diff --git a/client/disputes/evidence/test/fields.js b/client/disputes/evidence/test/fields.js
index d887fb60cb6..063373bff9d 100644
--- a/client/disputes/evidence/test/fields.js
+++ b/client/disputes/evidence/test/fields.js
@@ -30,7 +30,6 @@ const uncategorized = {
};
// Dispute fields per each dispute category and product type combination.
-/* eslint-disable camelcase */
const sectionsByReasonAndProductType = {
credit_not_processed: {
physical_product: [
@@ -248,7 +247,6 @@ const sectionsByReasonAndProductType = {
offline_service: [],
},
};
-/* eslint-enable camelcase */
// Convert hierarchical structure into set of tuples accepted by test runner.
const combinations = flatMap(
diff --git a/client/disputes/evidence/test/index.js b/client/disputes/evidence/test/index.js
index b8f577b8dfb..510113b45e6 100644
--- a/client/disputes/evidence/test/index.js
+++ b/client/disputes/evidence/test/index.js
@@ -14,7 +14,6 @@ jest.mock( 'data', () => ( {
useDisputeEvidence: jest.fn(),
} ) );
-/* eslint-disable camelcase */
const disputeNeedsResponse = {
id: 'dp_asdfghjkl',
amount: 1000,
@@ -46,7 +45,6 @@ const disputeNoNeedForResponse = {
reason: 'general',
status: 'under_review',
};
-/* eslint-enable camelcase */
const fields = [
{
diff --git a/client/disputes/info/test/index.js b/client/disputes/info/test/index.js
index f9561266612..0d4d62258d5 100644
--- a/client/disputes/info/test/index.js
+++ b/client/disputes/info/test/index.js
@@ -18,7 +18,6 @@ describe( 'Dispute info', () => {
} );
test( 'renders correctly', () => {
- /* eslint-disable camelcase */
const dispute = {
amount: 1000,
currency: 'usd',
@@ -39,7 +38,6 @@ describe( 'Dispute info', () => {
},
},
};
- /* eslint-enable camelcase */
const { container: info } = render( );
expect( info ).toMatchSnapshot();
diff --git a/client/disputes/strings.js b/client/disputes/strings.js
index 44635a54147..1345f1bc639 100644
--- a/client/disputes/strings.js
+++ b/client/disputes/strings.js
@@ -1,5 +1,4 @@
/** @format **/
-/* eslint-disable camelcase */
/* eslint-disable max-len */
/**
diff --git a/client/disputes/test/index.js b/client/disputes/test/index.js
index 7c8d4a700b1..5bd5978b555 100644
--- a/client/disputes/test/index.js
+++ b/client/disputes/test/index.js
@@ -30,22 +30,18 @@ describe( 'Disputes list', () => {
amount: 1000,
currency: 'usd',
created: 1572590800,
- // eslint-disable-next-line camelcase
evidence_details: {
- // eslint-disable-next-line camelcase
due_by: 1573199200,
},
reason: 'fraudulent',
status: 'needs_response',
charge: {
id: 'ch_mock',
- // eslint-disable-next-line camelcase
payment_method_details: {
card: {
brand: 'visa',
},
},
- // eslint-disable-next-line camelcase
billing_details: {
name: 'Mock customer',
email: 'mock@customer.net',
@@ -64,9 +60,7 @@ describe( 'Disputes list', () => {
amount: 1050,
currency: 'usd',
created: 1572480800,
- // eslint-disable-next-line camelcase
evidence_details: {
- // eslint-disable-next-line camelcase
due_by: 1573099200,
},
reason: 'general',
diff --git a/client/emtpy-state-table/deposits-banner.svg b/client/empty-state-table/deposits-banner.svg
similarity index 100%
rename from client/emtpy-state-table/deposits-banner.svg
rename to client/empty-state-table/deposits-banner.svg
diff --git a/client/emtpy-state-table/index.js b/client/empty-state-table/index.js
similarity index 100%
rename from client/emtpy-state-table/index.js
rename to client/empty-state-table/index.js
diff --git a/client/emtpy-state-table/list.js b/client/empty-state-table/list.js
similarity index 100%
rename from client/emtpy-state-table/list.js
rename to client/empty-state-table/list.js
diff --git a/client/emtpy-state-table/style.scss b/client/empty-state-table/style.scss
similarity index 100%
rename from client/emtpy-state-table/style.scss
rename to client/empty-state-table/style.scss
diff --git a/client/emtpy-state-table/transactions-banner.svg b/client/empty-state-table/transactions-banner.svg
similarity index 100%
rename from client/emtpy-state-table/transactions-banner.svg
rename to client/empty-state-table/transactions-banner.svg
diff --git a/client/fraud-scripts/forter.js b/client/fraud-scripts/forter.js
index 2c1b2ef0c2c..1e19bc0e28c 100644
--- a/client/fraud-scripts/forter.js
+++ b/client/fraud-scripts/forter.js
@@ -1,14 +1,15 @@
-/* eslint-disable camelcase */
-
-export default ( { site_id } ) => {
+export default ( { site_id: siteId } ) => {
// IDs in HTML can't start with a number, so calling querySelector('script#123456') breaks.
- if ( ! document.querySelector( 'script[id="' + site_id + '"]' ) ) {
+ if ( ! document.querySelector( 'script[id="' + siteId + '"]' ) ) {
const script = document.createElement( 'script' );
// Add the ID in case the Forter script looks for it in the page.
- script.id = site_id;
+ script.id = siteId;
// TODO: This is sent to the checkout JS bundle too. That's not ideal, it's pretty big.
- // eslint-disable-next-line
- script.textContent = '(function () {var eu = \'g68x4yj4t5;e6z1forxgiurqw1qhw2vq2(VQ(2vfulsw1mv\';var siteId = "' + site_id + '";function t(t,e){for(var n=t.split(""),r=0;r>8&255]+n[t>>16&255]+n[t>>24&255]+c+n[255&e]+n[e>>8&255]+c+n[e>>16&15|64]+n[e>>24&255]+c+n[63&r|128]+n[r>>8&255]+c+n[r>>16&255]+n[r>>24&255]+n[255&o]+n[o>>8&255]+n[o>>16&255]+n[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",e=function(t,e){for(var n="",r=t;r>0;--r)n+=e.charAt(1e3*Math.random()%e.length);return n};return t+=e(2,"0123456789"),t+=e(1,"123456789"),t+=e(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(n){try{return e+c()}catch(n){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(e)&&t.length>=12},t}(),S={uDF:"UDF",uAL:"UAL",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",cP:"c"},k=function(t,e){for(var n=S.tmos,r=0;r>8&255]+n[t>>16&255]+n[t>>24&255]+c+n[255&e]+n[e>>8&255]+c+n[e>>16&15|64]+n[e>>24&255]+c+n[63&r|128]+n[r>>8&255]+c+n[r>>16&255]+n[r>>24&255]+n[255&o]+n[o>>8&255]+n[o>>16&255]+n[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",e=function(t,e){for(var n="",r=t;r>0;--r)n+=e.charAt(1e3*Math.random()%e.length);return n};return t+=e(2,"0123456789"),t+=e(1,"123456789"),t+=e(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(n){try{return e+c()}catch(n){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(e)&&t.length>=12},t}(),S={uDF:"UDF",uAL:"UAL",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",cP:"c"},k=function(t,e){for(var n=S.tmos,r=0;r {
+export default ( {
+ beacon_key: beaconKey,
+ session_id: sessionId,
+ user_id: userId,
+} ) => {
const _sift = ( window._sift = window._sift || [] );
- _sift.push( [ '_setAccount', beacon_key ] );
- _sift.push( [ '_setUserId', user_id ] );
- _sift.push( [ '_setSessionId', session_id ] );
+ _sift.push( [ '_setAccount', beaconKey ] );
+ _sift.push( [ '_setUserId', userId ] );
+ _sift.push( [ '_setSessionId', sessionId ] );
_sift.push( [ '_trackPageview' ] );
if ( ! document.querySelector( `[src="${ src }"]` ) ) {
diff --git a/client/globals.d.ts b/client/globals.d.ts
new file mode 100644
index 00000000000..bda87ba87c0
--- /dev/null
+++ b/client/globals.d.ts
@@ -0,0 +1,7 @@
+declare const wcpaySettings: {
+ isSubscriptionsActive: boolean;
+ featureFlags: {
+ customSearch: boolean;
+ };
+ fraudServices: unknown[];
+};
diff --git a/client/multi-currency/enabled-currencies-list/index.js b/client/multi-currency/enabled-currencies-list/index.js
index dc4dc198899..d1acbc81276 100644
--- a/client/multi-currency/enabled-currencies-list/index.js
+++ b/client/multi-currency/enabled-currencies-list/index.js
@@ -54,7 +54,7 @@ const EnabledCurrencies = () => {
{
const getEditUrl = ( currencyId ) => {
return `admin.php?page=wc-settings&tab=wcpay_multi_currency§ion=${ currencyId.toLowerCase() }`;
};
- const formattedRate = Number.parseFloat( rate ).toFixed( 2 );
+ const formatCurrencyRate = () => {
+ const formattedRate = isDefaultZeroDecimal
+ ? Number.parseFloat( rate * 1000 ).toFixed( 2 )
+ : Number.parseFloat( rate ).toFixed( 2 );
+
+ if ( isDefault ) {
+ return __( 'Default currency', 'woocommerce-payments' );
+ }
+
+ return isDefaultZeroDecimal
+ ? `1,000 ${ defaultCode } → ${ formattedRate } ${ code }`
+ : `1 ${ defaultCode } → ${ formattedRate } ${ code }`;
+ };
return (
@@ -33,12 +47,7 @@ const EnabledCurrenciesListItem = ( {