Skip to content

Commit

Permalink
Temporarily revert #9439 multi-currency v2 (#9468)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardo authored Sep 20, 2024
1 parent 30a1d96 commit 4c417bc
Show file tree
Hide file tree
Showing 204 changed files with 1,365 additions and 1,927 deletions.
4 changes: 0 additions & 4 deletions changelog/multi-currency-v2

This file was deleted.

5 changes: 5 additions & 0 deletions changelog/revert-9439-multi-currency-v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Revert "Decoupled Multi-currency module from gateway dependencies."


Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import PaymentMethodCheckbox from '../../components/payment-methods-checkboxes/p
import { LoadableBlock } from '../../components/loadable';
import LoadableSettingsSection from '../../settings/loadable-settings-section';
import CurrencyInformationForMethods from './currency-information-for-methods';
import { getMissingCurrenciesTooltipMessage } from 'multi-currency/interface/functions';
import { getMissingCurrenciesTooltipMessage } from 'wcpay/multi-currency/missing-currencies-message';
import { upeCapabilityStatuses, upeMethods } from '../constants';
import paymentMethodsMap from '../../payment-methods-map';
import ConfirmPaymentMethodActivationModal from 'wcpay/settings/payment-methods-list/activation-modal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import interpolateComponents from '@automattic/interpolate-components';
/**
* Internal dependencies
*/
import { useAccountDomesticCurrency } from '../../data';
import {
useAccountDomesticCurrency,
useCurrencies,
useEnabledCurrencies,
} from 'multi-currency/interface/data';
} from '../../data';
import WCPaySettingsContext from '../../settings/wcpay-settings-context';
import InlineNotice from 'components/inline-notice';
import PaymentMethodsMap from '../../payment-methods-map';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,25 @@ import {
useEnabledPaymentMethodIds,
useGetPaymentMethodStatuses,
useSettings,
useCurrencies,
useEnabledCurrencies,
useManualCapture,
useAccountDomesticCurrency,
} from '../../../data';
import {
useCurrencies,
useEnabledCurrencies,
} from 'multi-currency/interface/data';

import WCPaySettingsContext from '../../../settings/wcpay-settings-context';
import { upeCapabilityStatuses } from 'wcpay/additional-methods-setup/constants';

jest.mock( '../../../data', () => ( {
useGetAvailablePaymentMethodIds: jest.fn(),
useEnabledPaymentMethodIds: jest.fn(),
useSettings: jest.fn(),
useCurrencies: jest.fn(),
useEnabledCurrencies: jest.fn(),
useGetPaymentMethodStatuses: jest.fn(),
useManualCapture: jest.fn(),
useAccountDomesticCurrency: jest.fn(),
} ) );

jest.mock( 'multi-currency/interface/data', () => ( {
useCurrencies: jest.fn(),
useEnabledCurrencies: jest.fn(),
} ) );

jest.mock( '@wordpress/a11y', () => ( {
...jest.requireActual( '@wordpress/a11y' ),
speak: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ import { render, screen } from '@testing-library/react';
/**
* Internal dependencies
*/
import { useAccountDomesticCurrency } from '../../../data';
import {
useCurrencies,
useEnabledCurrencies,
} from 'multi-currency/interface/data';
useAccountDomesticCurrency,
} from 'wcpay/data';
import CurrencyInformationForMethods from '../currency-information-for-methods';
import WCPaySettingsContext from '../../../settings/wcpay-settings-context';

jest.mock( '../../../data', () => ( {
useAccountDomesticCurrency: jest.fn(),
} ) );

jest.mock( 'multi-currency/interface/data', () => ( {
jest.mock( 'wcpay/data', () => ( {
useCurrencies: jest.fn(),
useEnabledCurrencies: jest.fn(),
useAccountDomesticCurrency: jest.fn(),
} ) );

jest.mock( '@wordpress/a11y', () => ( {
Expand Down
18 changes: 1 addition & 17 deletions client/additional-methods-setup/wizard/task-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import { Icon, check } from '@wordpress/icons';
import WizardTaskContext from './task/context';
import './task-item.scss';

const WizardTaskItem = ( {
children,
title,
index,
className,
visibleDescription,
} ) => {
const WizardTaskItem = ( { children, title, index, className } ) => {
const { isCompleted, isActive } = useContext( WizardTaskContext );

return (
Expand Down Expand Up @@ -45,16 +39,6 @@ const WizardTaskItem = ( {
</div>
<span className="wcpay-wizard-task__title">{ title }</span>
</div>
{ visibleDescription && ! isActive && (
<span
className={ classNames(
'wcpay-wizard-task__visible-description-element',
'is-muted-color'
) }
>
{ visibleDescription }
</span>
) }
<div className="wcpay-wizard-task__body">{ children }</div>
</li>
);
Expand Down
16 changes: 0 additions & 16 deletions client/additional-methods-setup/wizard/task-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,6 @@
}
}

&__visible-description-element {
position: absolute;
margin-left: 40px;
margin-top: 0;
margin-bottom: 1em;

&.is-muted-color {
color: $gray-700;
}

.components-external-link svg {
width: 1em;
height: 1em;
}
}

.add-payment-methods-task {
&__payment-selector {
&-wrapper {
Expand Down
5 changes: 1 addition & 4 deletions client/capital/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import Page from 'components/page';
import { TestModeNotice } from 'components/test-mode-notice';
import ErrorBoundary from 'components/error-boundary';
import ActiveLoanSummary from 'components/active-loan-summary';
import {
formatExplicitCurrency,
isZeroDecimalCurrency,
} from 'multi-currency/interface/functions';
import { formatExplicitCurrency, isZeroDecimalCurrency } from 'utils/currency';
import { CapitalLoan } from 'data/capital/types';
import ClickableCell from 'components/clickable-cell';
import Chip from 'components/chip';
Expand Down
2 changes: 1 addition & 1 deletion client/checkout/woopay/email-input-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { buildAjaxURL } from 'utils/express-checkout';
import { getAppearance } from 'checkout/upe-styles';
import {
getTargetElement,
getAppearanceType,
validateEmail,
appendRedirectionParams,
shouldSkipWooPay,
deleteSkipWooPayCookie,
} from './utils';
import { getAppearanceType } from '../utils';

export const handleWooPayEmailInput = async (
field,
Expand Down
2 changes: 1 addition & 1 deletion client/components/account-balances/balance-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as React from 'react';
/**
* Internal dependencies
*/
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatCurrency } from 'wcpay/utils/currency';
import Loadable from 'components/loadable';

/**
Expand Down
2 changes: 1 addition & 1 deletion client/components/account-balances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from './balance-tooltip';
import { fundLabelStrings } from './strings';
import { ClickTooltip } from '../tooltip';
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatCurrency } from 'wcpay/utils/currency';
import { useAllDepositsOverviews } from 'wcpay/data';
import { useSelectedCurrency } from 'wcpay/overview/hooks';
import './style.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Internal dependencies
*/
import ProgressBar from 'components/progress-bar';
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatCurrency } from 'utils/currency';

const ExpirationBar = ( {
feeData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import moment from 'moment';
/**
* Internal dependencies
*/
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatCurrency } from 'utils/currency';

const ExpirationDescription = ( {
feeData: { volume_allowance: volumeAllowance, end_time: endTime, ...rest },
Expand Down
5 changes: 1 addition & 4 deletions client/components/account-status/account-fees/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { __ } from '@wordpress/i18n';
*/
import ExpirationBar from './expiration-bar';
import ExpirationDescription from './expiration-description';
import {
formatCurrencyName,
getCurrency,
} from 'multi-currency/interface/functions';
import { formatCurrencyName, getCurrency } from 'utils/currency';
import {
formatAccountFeesDescription,
getCurrentBaseFee,
Expand Down
2 changes: 1 addition & 1 deletion client/components/active-loan-summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { dateI18n } from '@wordpress/date';
/**
* Internal dependencies.
*/
import { formatExplicitCurrency } from 'multi-currency/interface/functions';
import { formatExplicitCurrency } from 'utils/currency';
import Loadable from 'components/loadable';
import { useActiveLoanSummary } from 'wcpay/data';
import { getAdminUrl } from 'wcpay/utils';
Expand Down
2 changes: 1 addition & 1 deletion client/components/deposits-overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getHistory } from '@woocommerce/navigation';
* Internal dependencies.
*/
import { getAdminUrl } from 'wcpay/utils';
import { formatExplicitCurrency } from 'multi-currency/interface/functions';
import { formatExplicitCurrency } from 'wcpay/utils/currency';
import { recordEvent } from 'tracks';
import Loadable from 'components/loadable';
import { useSelectedCurrencyOverview } from 'wcpay/overview/hooks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import './style.scss';
import DepositStatusChip from 'components/deposit-status-chip';
import { getDepositDate } from 'deposits/utils';
import { CachedDeposit } from 'wcpay/types/deposits';
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatCurrency } from 'wcpay/utils/currency';
import { getDetailsURL } from 'wcpay/components/details-link';

interface RecentDepositsProps {
Expand Down
2 changes: 1 addition & 1 deletion client/components/disputed-order-notice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createInterpolateElement } from '@wordpress/element';
* Internal dependencies
*/
import InlineNotice from 'wcpay/components/inline-notice';
import { formatExplicitCurrency } from 'multi-currency/interface/functions';
import { formatExplicitCurrency } from 'utils/currency';
import { reasons } from 'wcpay/disputes/strings';
import { getDetailsURL } from 'wcpay/components/details-link';
import {
Expand Down
2 changes: 1 addition & 1 deletion client/components/payment-activity/payment-data-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { recordEvent } from 'wcpay/tracks';
/**
* Internal dependencies
*/
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatCurrency } from 'wcpay/utils/currency';
import Loadable from '../loadable';
import './style.scss';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion client/components/welcome/currency-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { decodeEntities } from '@wordpress/html-entities';
* Internal dependencies
*/
import { useSelectedCurrency } from 'overview/hooks';
import { getCurrency } from 'multi-currency/interface/functions';
import { getCurrency } from 'utils/currency';
import InlineLabelSelect from '../inline-label-select';
import { recordEvent } from 'tracks';

Expand Down
2 changes: 1 addition & 1 deletion client/data/deposits/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { apiFetch } from '@wordpress/data-controls';
import { dispatch } from '@wordpress/data';
import { __, sprintf } from '@wordpress/i18n';
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatCurrency } from 'utils/currency';

/**
* Internal Dependencies
Expand Down
1 change: 1 addition & 0 deletions client/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export * from './charges/hooks';
export * from './timeline/hooks';
export * from './disputes/hooks';
export * from './settings/hooks';
export * from './multi-currency';
export * from './card-readers/hooks';
export * from './capital/hooks';
export * from './documents/hooks';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import { apiFetch } from '@wordpress/data-controls';
import { dispatch, select } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { recordEvent } from 'tracks';

/**
* Internal Dependencies
*/
import { recordEvent } from 'multi-currency/interface/functions';
import TYPES from './action-types';
import { NAMESPACE, STORE_NAME } from './constants';
import { NAMESPACE, STORE_NAME } from '../constants';

export function updateCurrencies( data ) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
* External dependencies
*/
import { useSelect, useDispatch, dispatch } from '@wordpress/data';

/**
* Internal dependencies
*/
import { STORE_NAME } from './constants';
import { STORE_NAME } from '../constants';

export const useCurrencies = () =>
useSelect( ( select ) => {
Expand Down
12 changes: 12 additions & 0 deletions client/data/multi-currency/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @format */

/**
* Internal dependencies
*/
import reducer from './reducer';
import * as selectors from './selectors';
import * as actions from './actions';
import * as resolvers from './resolvers';

export { reducer, selectors, actions, resolvers };
export * from './hooks';
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { NAMESPACE } from './constants';
import { NAMESPACE } from '../constants';
import {
updateCurrencies,
updateCurrencySettings,
Expand All @@ -34,7 +34,7 @@ export function* getCurrencies() {
}

/**
* Retrieve single currency settings from the site's REST API.
* Retrieve single currency sttings from the site's REST API.
*
* @param {string} currencyCode The currency code to fetch settings for.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getMultiCurrencyState = ( state ) => {
return {};
}

return state || {};
return state.multiCurrency || {};
};

export const getCurrencies = ( state ) => {
Expand Down
Loading

0 comments on commit 4c417bc

Please sign in to comment.