Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoupled Multi-currency module from gateway dependencies #9439

Merged
merged 17 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/multi-currency-v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

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 'wcpay/multi-currency/missing-currencies-message';
import { getMissingCurrenciesTooltipMessage } from 'multi-currency/interface/functions';
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 '../../data';
} from 'multi-currency/interface/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,25 +22,31 @@ 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,18 +7,21 @@ import { render, screen } from '@testing-library/react';
/**
* Internal dependencies
*/
import { useAccountDomesticCurrency } from '../../../data';
import {
useCurrencies,
useEnabledCurrencies,
useAccountDomesticCurrency,
} from 'wcpay/data';
} from 'multi-currency/interface/data';
import CurrencyInformationForMethods from '../currency-information-for-methods';
import WCPaySettingsContext from '../../../settings/wcpay-settings-context';

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

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

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

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

return (
Expand Down Expand Up @@ -39,6 +45,16 @@ const WizardTaskItem = ( { children, title, index, className } ) => {
</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: 16 additions & 0 deletions client/additional-methods-setup/wizard/task-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@
}
}

&__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: 4 additions & 1 deletion client/capital/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ 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 'utils/currency';
import {
formatExplicitCurrency,
isZeroDecimalCurrency,
} from 'multi-currency/interface/functions';
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 'wcpay/utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';
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 'wcpay/utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';
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 'utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';

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 'utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';

const ExpirationDescription = ( {
feeData: { volume_allowance: volumeAllowance, end_time: endTime, ...rest },
Expand Down
5 changes: 4 additions & 1 deletion client/components/account-status/account-fees/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { __ } from '@wordpress/i18n';
*/
import ExpirationBar from './expiration-bar';
import ExpirationDescription from './expiration-description';
import { formatCurrencyName, getCurrency } from 'utils/currency';
import {
formatCurrencyName,
getCurrency,
} from 'multi-currency/interface/functions';
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 'utils/currency';
import { formatExplicitCurrency } from 'multi-currency/interface/functions';
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 'wcpay/utils/currency';
import { formatExplicitCurrency } from 'multi-currency/interface/functions';
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 'wcpay/utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';
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 'utils/currency';
import { formatExplicitCurrency } from 'multi-currency/interface/functions';
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 'wcpay/utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';
import Loadable from '../loadable';
import './style.scss';

Expand Down
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 'utils/currency';
import { getCurrency } from 'multi-currency/interface/functions';
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 'utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';

/**
* Internal Dependencies
Expand Down
1 change: 0 additions & 1 deletion client/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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
12 changes: 0 additions & 12 deletions client/data/multi-currency/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions client/data/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import * as charges from './charges';
import * as timeline from './timeline';
import * as disputes from './disputes';
import * as settings from './settings';
import * as multiCurrency from './multi-currency';
import * as readers from './card-readers';
import * as capital from './capital';
import * as documents from './documents';
Expand All @@ -33,7 +32,6 @@ export const initStore = () =>
timeline: timeline.reducer,
disputes: disputes.reducer,
settings: settings.reducer,
multiCurrency: multiCurrency.reducer,
readers: readers.reducer,
capital: capital.reducer,
documents: documents.reducer,
Expand All @@ -49,7 +47,6 @@ export const initStore = () =>
...timeline.actions,
...disputes.actions,
...settings.actions,
...multiCurrency.actions,
...readers.actions,
...capital.actions,
...documents.actions,
Expand All @@ -66,7 +63,6 @@ export const initStore = () =>
...timeline.selectors,
...disputes.selectors,
...settings.selectors,
...multiCurrency.selectors,
...readers.selectors,
...capital.selectors,
...documents.selectors,
Expand All @@ -82,7 +78,6 @@ export const initStore = () =>
...timeline.resolvers,
...disputes.resolvers,
...settings.resolvers,
...multiCurrency.resolvers,
...readers.resolvers,
...capital.resolvers,
...documents.resolvers,
Expand Down
5 changes: 4 additions & 1 deletion client/deposits/details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import Page from 'components/page';
import ErrorBoundary from 'components/error-boundary';
import { TestModeNotice } from 'components/test-mode-notice';
import InlineNotice from 'components/inline-notice';
import { formatCurrency, formatExplicitCurrency } from 'utils/currency';
import {
formatCurrency,
formatExplicitCurrency,
} from 'multi-currency/interface/functions';
import { displayStatus } from '../strings';
import './style.scss';

Expand Down
2 changes: 1 addition & 1 deletion client/deposits/filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getQuery } from '@woocommerce/navigation';
* Internal dependencies
*/
import { filters, advancedFilters } from './config';
import { formatCurrencyName } from '../../utils/currency';
import { formatCurrencyName } from 'multi-currency/interface/functions';

export const DepositsFilters = ( props ) => {
const populateDepositCurrencies = ( filtersConfiguration ) => {
Expand Down
2 changes: 1 addition & 1 deletion client/deposits/instant-deposits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useState } from '@wordpress/element';
* Internal dependencies
*/
import './style.scss';
import { formatCurrency } from 'wcpay/utils/currency';
import { formatCurrency } from 'multi-currency/interface/functions';
import InstantDepositModal from './modal';
import { useInstantDeposit } from 'wcpay/data';
import type * as AccountOverview from 'wcpay/types/account-overview';
Expand Down
5 changes: 4 additions & 1 deletion client/deposits/instant-deposits/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import { formatCurrency, formatExplicitCurrency } from 'utils/currency';
import {
formatCurrency,
formatExplicitCurrency,
} from 'multi-currency/interface/functions';
import type * as AccountOverview from 'wcpay/types/account-overview';
import './style.scss';

Expand Down
5 changes: 4 additions & 1 deletion client/deposits/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import { useDispatch } from '@wordpress/data';
import { useDeposits, useDepositsSummary } from 'wcpay/data';
import { useReportingExportLanguage } from 'data/index';
import { displayType, displayStatus } from '../strings';
import { formatExplicitCurrency, formatExportAmount } from 'utils/currency';
import {
formatExplicitCurrency,
formatExportAmount,
} from 'multi-currency/interface/functions';
import DetailsLink, { getDetailsURL } from 'components/details-link';
import ClickableCell from 'components/clickable-cell';
import Page from '../../components/page';
Expand Down
Loading
Loading