Skip to content

Commit

Permalink
Merge branch 'develop' into fix/tokenized-ece-pay-for-order-without-b…
Browse files Browse the repository at this point in the history
…illing-email
  • Loading branch information
frosso authored Dec 20, 2024
2 parents 3d20573 + 3794508 commit 8848e29
Show file tree
Hide file tree
Showing 76 changed files with 984 additions and 300 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Apply User-Defined Date Formatting Settings to WP Admin React Components
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Use translatable strings on the fee breakdown tooltip of the payment settings screen.
4 changes: 4 additions & 0 deletions changelog/fix-9735-render-transactions-correctly-on-capture
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Ensure captured transactions appear in the Transactions tab without requiring a page refresh.
5 changes: 5 additions & 0 deletions changelog/update-s6837-reduce-api-impact-for-test-drive-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: update
Comment: Reduce the maximum number of API calls during the test-drive process and add maximum duration cut off logic.


12 changes: 8 additions & 4 deletions client/capital/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import * as React from 'react';
import { __, _n } from '@wordpress/i18n';
import { TableCard } from '@woocommerce/components';
import { dateI18n } from '@wordpress/date';

/**
* Internal dependencies.
Expand All @@ -25,6 +24,8 @@ import Chip from 'components/chip';
import { useLoans } from 'wcpay/data';
import { getAdminUrl } from 'wcpay/utils';
import './style.scss';
import { formatDateTimeFromString } from 'wcpay/utils/date-time';
import DateFormatNotice from 'wcpay/components/date-format-notice';

const columns = [
{
Expand Down Expand Up @@ -80,7 +81,7 @@ const getLoanStatusText = ( loan: CapitalLoan ) => {
return loan.fully_paid_at
? __( 'Paid off', 'woocommerce-payments' ) +
': ' +
dateI18n( 'M j, Y', loan.fully_paid_at )
formatDateTimeFromString( loan.fully_paid_at )
: __( 'Active', 'woocommerce-payments' );
};

Expand Down Expand Up @@ -112,7 +113,9 @@ const getRowsData = ( loans: CapitalLoan[] ) =>
const data = {
paid_out_at: {
value: loan.paid_out_at,
display: clickable( dateI18n( 'M j, Y', loan.paid_out_at ) ),
display: clickable(
formatDateTimeFromString( loan.paid_out_at )
),
},
status: {
value: getLoanStatusText( loan ),
Expand Down Expand Up @@ -150,7 +153,7 @@ const getRowsData = ( loans: CapitalLoan[] ) =>
value: loan.first_paydown_at,
display: clickable(
loan.first_paydown_at
? dateI18n( 'M j, Y', loan.first_paydown_at )
? formatDateTimeFromString( loan.first_paydown_at )
: '-'
),
},
Expand Down Expand Up @@ -207,6 +210,7 @@ const CapitalPage = (): JSX.Element => {

return (
<Page>
<DateFormatNotice />
<TestModeNotice currentPage="loans" />

{ wcpaySettings.accountLoans.has_active_loan && (
Expand Down
48 changes: 48 additions & 0 deletions client/capital/test/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,54 @@ exports[`CapitalPage renders the TableCard component with loan data 1`] = `
<div
class=" woocommerce-payments-page"
>
<div
class="date-format-notice wcpay-banner-notice is-info"
>
<svg
aria-hidden="true"
class="wcpay-banner-notice__icon"
focusable="false"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"
/>
</svg>
<div
class="wcpay-banner-notice__content"
>
The date and time formats now match your preferences. You can update them anytime in the
<a
data-link-type="external"
href="/wp-admin/options-general.php"
>
settings
</a>
.
</div>
<button
aria-label="Dismiss this notice"
class="components-button wcpay-banner-notice__dismiss has-icon"
type="button"
>
<svg
class="gridicon gridicons-cross-small"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<path
d="M17.705 7.705l-1.41-1.41L12 10.59 7.705 6.295l-1.41 1.41L10.59 12l-4.295 4.295 1.41 1.41L12 13.41l4.295 4.295 1.41-1.41L13.41 12l4.295-4.295z"
/>
</g>
</svg>
</button>
</div>
<div
class="wcpay-banner-notice is-warning"
>
Expand Down
2 changes: 2 additions & 0 deletions client/capital/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare const global: {
accountLoans: {
has_active_loan: boolean;
};
dateFormat: string;
};
};

Expand All @@ -37,6 +38,7 @@ describe( 'CapitalPage', () => {
},
accountLoans: { has_active_loan: true },
testMode: true,
dateFormat: 'M j, Y',
};
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* External dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { dateI18n } from '@wordpress/date';
import moment from 'moment';

/**
* Internal dependencies
*/
import { formatCurrency } from 'multi-currency/interface/functions';
import { formatDateTimeFromString } from 'wcpay/utils/date-time';

const ExpirationDescription = ( {
feeData: { volume_allowance: volumeAllowance, end_time: endTime, ...rest },
Expand All @@ -26,7 +25,7 @@ const ExpirationDescription = ( {
'woocommerce-payments'
),
formatCurrency( volumeAllowance, currencyCode ),
dateI18n( 'F j, Y', moment( endTime ).toISOString() )
formatDateTimeFromString( endTime )
);
} else if ( volumeAllowance ) {
description = sprintf(
Expand All @@ -44,7 +43,7 @@ const ExpirationDescription = ( {
'Discounted base fee expires on %1$s.',
'woocommerce-payments'
),
dateI18n( 'F j, Y', moment( endTime ).toISOString() )
formatDateTimeFromString( endTime )
);
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe( 'AccountFees', () => {
precision: 2,
},
},
dateFormat: 'F j, Y',
};
} );

Expand Down
20 changes: 7 additions & 13 deletions client/components/active-loan-summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
import { dateI18n } from '@wordpress/date';

/**
* Internal dependencies.
Expand All @@ -24,6 +23,7 @@ import { useActiveLoanSummary } from 'wcpay/data';
import { getAdminUrl } from 'wcpay/utils';

import './style.scss';
import { formatDateTimeFromTimestamp } from 'wcpay/utils/date-time';

const Block = ( {
title,
Expand Down Expand Up @@ -210,12 +210,8 @@ const ActiveLoanSummary = (): JSX.Element => {
'Repaid this period (until %s)',
'woocommerce-payments'
),
dateI18n(
'M j, Y',
new Date(
details.current_repayment_interval.due_at *
1000
)
formatDateTimeFromTimestamp(
details.current_repayment_interval.due_at
)
) }
>
Expand Down Expand Up @@ -251,9 +247,8 @@ const ActiveLoanSummary = (): JSX.Element => {
<Block
title={ __( 'Loan disbursed', 'woocommerce-payments' ) }
>
{ dateI18n(
'M j, Y',
new Date( details.advance_paid_out_at * 1000 )
{ formatDateTimeFromTimestamp(
details.advance_paid_out_at
) }
</Block>
<Block
Expand All @@ -278,9 +273,8 @@ const ActiveLoanSummary = (): JSX.Element => {
<Block
title={ __( 'First paydown', 'woocommerce-payments' ) }
>
{ dateI18n(
'M j, Y',
new Date( details.repayments_begin_at * 1000 )
{ formatDateTimeFromTimestamp(
details.repayments_begin_at
) }
</Block>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ exports[`Active loan summary renders correctly 1`] = `
<div
class="wcpay-loan-summary-block__title"
>
Repaid this period (until Feb 14, 2022)
Repaid this period (until Feb 15, 2022)
</div>
<div
class="wcpay-loan-summary-block__value"
Expand Down
10 changes: 10 additions & 0 deletions client/components/active-loan-summary/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jest.mock( 'wcpay/data', () => ( {
useActiveLoanSummary: jest.fn(),
} ) );

// Mock dateI18n
jest.mock( '@wordpress/date', () => ( {
dateI18n: jest.fn( ( format, date ) => {
return jest
.requireActual( '@wordpress/date' )
.dateI18n( format, date, 'UTC' ); // Ensure UTC is used
} ),
} ) );

describe( 'Active loan summary', () => {
beforeEach( () => {
global.wcpaySettings = {
Expand All @@ -34,6 +43,7 @@ describe( 'Active loan summary', () => {
precision: 2,
},
},
dateFormat: 'M j, Y',
};
} );
afterEach( () => {
Expand Down
67 changes: 67 additions & 0 deletions client/components/date-format-notice/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* External dependencies
*/
import React, { useState } from 'react';
import { __ } from '@wordpress/i18n';
import { useDispatch } from '@wordpress/data';

/**
* Internal dependencies
*/
import BannerNotice from 'components/banner-notice';
import interpolateComponents from '@automattic/interpolate-components';
import { Link } from '@woocommerce/components';
import './style.scss';

const optionName = 'wcpay_date_format_notice_dismissed';

const DateFormatNotice: React.FC = () => {
const { updateOptions } = useDispatch( 'wc/admin/options' );
const [ isBannerVisible, setIsBannerVisible ] = useState(
! wcpaySettings.isDateFormatNoticeDismissed
);

const handleDismiss = () => {
setIsBannerVisible( false );
wcpaySettings.isDateFormatNoticeDismissed = true;
updateOptions( {
[ optionName ]: true,
} );
};

const handleSettingsClick = () => {
handleDismiss();
};

if ( ! isBannerVisible ) {
return null;
}

return (
<BannerNotice
status="info"
icon={ true }
isDismissible={ true }
onRemove={ handleDismiss }
className="date-format-notice"
>
{ interpolateComponents( {
components: {
settingsLink: (
<Link
href={ '/wp-admin/options-general.php' }
onClick={ handleSettingsClick }
type="external"
/>
),
},
mixedString: __(
'The date and time formats now match your preferences. You can update them anytime in the {{settingsLink}}settings{{/settingsLink}}.',
'woocommerce-payments'
),
} ) }
</BannerNotice>
);
};

export default DateFormatNotice;
5 changes: 5 additions & 0 deletions client/components/date-format-notice/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.date-format-notice {
.wcpay-banner-notice__content {
align-self: center; // Align the content to the center of the notice and the icon.
}
}
2 changes: 2 additions & 0 deletions client/components/deposits-overview/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ declare const global: {
connect: {
country: string;
};
dateFormat: string;
};
};

Expand Down Expand Up @@ -240,6 +241,7 @@ describe( 'Deposits Overview information', () => {
precision: 2,
},
},
dateFormat: 'F j, Y',
};
mockUseDepositIncludesLoan.mockReturnValue( {
includesFinancingPayout: false,
Expand Down
Loading

0 comments on commit 8848e29

Please sign in to comment.