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

Use 'Withdrawal' and 'Deducted' labels when referring to withdrawal deposits, to more accurately communicate the type of transaction that has occurred #9500

Merged
merged 29 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dda3707
Show paid withdrawals as 'Deducted' in deposit status chip
Jinksi Sep 27, 2024
ab2ac05
Show paid withdrawals as 'Deducted' in deposit detail screen status i…
Jinksi Sep 27, 2024
e0ae386
Fix imported dependency order to improve code quality
Jinksi Sep 27, 2024
2b345b7
Replace 'Deposit' with 'Withdrawal' on deposit details screen
Jinksi Sep 27, 2024
146eec5
Don't use 'deducted' status for deposit list advanced filters or queries
Jinksi Sep 27, 2024
ab764e3
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Sep 29, 2024
d3873ae
Rename `displayStatus` to `depositStatusLabels` to improve clarity
Jinksi Oct 1, 2024
e97d829
Add changelog entry
Jinksi Oct 1, 2024
ea76c62
Render advanced filter deposit status label as 'Paid / Deducted' to m…
Jinksi Oct 1, 2024
b1d8326
Add DepositOverview test case for withdrawal labels
Jinksi Oct 1, 2024
28fa3b5
Add a withdrawal test case to the DepositsOverview component tests
Jinksi Oct 1, 2024
7d1b4d1
Add a withdrawal test case to the deposits list snapshots
Jinksi Oct 1, 2024
2db4e34
Add a withdrawal test case to the transactions list snapshots
Jinksi Oct 1, 2024
bbd6e4e
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Oct 1, 2024
cbbf62c
Simplify the deposit details heading `Deposit / Withdrawal transactio…
Jinksi Oct 2, 2024
6bdfbce
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Oct 16, 2024
9f33dbb
Add "Type" column to payments overview recent deposits list
Jinksi Oct 17, 2024
95d44ac
Update snapshot for deposits overview
Jinksi Oct 17, 2024
8ea82da
Prefer inferred types to simplify code
Jinksi Oct 17, 2024
08fad5b
Change Paid / Deducted to Completed (paid/deducted)
Jinksi Oct 17, 2024
334a5c7
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Oct 20, 2024
3473f80
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Oct 28, 2024
cf6ab74
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Oct 29, 2024
acf6ede
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Oct 30, 2024
4a18b89
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Oct 31, 2024
bee6b8f
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Nov 3, 2024
e806f82
Revert "Add "Type" column to payments overview recent deposits list"
Jinksi Nov 5, 2024
6106fc1
Revert "Update snapshot for deposits overview"
Jinksi Nov 5, 2024
59b3c3c
Merge branch 'develop' into fix/7802-deposit-withdrawal-text-changes
Jinksi Nov 6, 2024
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/fix-7802-deposit-withdrawal-text-changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Use 'Withdrawal' and 'Deducted' labels when referring to withdrawal deposits, to more accurately communicate the type of transaction that has occurred
20 changes: 12 additions & 8 deletions client/components/deposit-status-chip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import * as React from 'react';
/**
* Internal dependencies
*/
import { displayStatus } from 'deposits/strings';
import Chip, { ChipType } from 'components/chip';
import type { DepositStatus } from 'wcpay/types/deposits';
import type { CachedDeposit, DepositStatus } from 'wcpay/types/deposits';
import { depositStatusLabels } from 'wcpay/deposits/strings';

/**
* Maps a DepositStatus to a ChipType.
Expand All @@ -23,13 +23,17 @@ const mappings: Record< DepositStatus, ChipType > = {

/**
* Renders a deposits status chip.
*
* @return {JSX.Element} Deposit status chip.
*/
const DepositStatusChip: React.FC< {
status: DepositStatus;
} > = ( { status } ): JSX.Element => (
<Chip type={ mappings[ status ] } message={ displayStatus[ status ] } />
);
deposit: Pick< CachedDeposit, 'status' | 'type' >;
} > = ( { deposit } ) => {
let message = depositStatusLabels[ deposit.status ];

// Withdrawals are displayed as 'Deducted' instead of 'Paid'.
if ( deposit.type === 'withdrawal' && deposit.status === 'paid' ) {
message = depositStatusLabels.deducted;
}
return <Chip type={ mappings[ deposit.status ] } message={ message } />;
};

export default DepositStatusChip;
18 changes: 14 additions & 4 deletions client/components/deposit-status-chip/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,28 @@ import DepositStatusChip from '..';

describe( 'Deposits status chip renders', () => {
test( 'Renders "Pending" status chip.', () => {
const { getByText } = render( <DepositStatusChip status="pending" /> );
const { getByText } = render(
<DepositStatusChip
deposit={ { type: 'deposit', status: 'pending' } }
/>
);
expect( getByText( 'Pending' ) ).toBeTruthy();
} );

test( 'Renders "Paid" status chip.', () => {
const { getByText } = render( <DepositStatusChip status="paid" /> );
expect( getByText( 'Paid' ) ).toBeTruthy();
const { getByText } = render(
<DepositStatusChip
deposit={ { type: 'deposit', status: 'paid' } }
/>
);
expect( getByText( 'Completed (paid)' ) ).toBeTruthy();
} );

test( 'Renders "In transit" status chip.', () => {
const { getByText } = render(
<DepositStatusChip status="in_transit" />
<DepositStatusChip
deposit={ { type: 'deposit', status: 'in_transit' } }
/>
);
expect( getByText( 'In transit' ) ).toBeTruthy();
} );
Expand Down
10 changes: 8 additions & 2 deletions client/components/deposits-overview/recent-deposits-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from '@wordpress/components';
import { calendar } from '@wordpress/icons';
import { Link } from '@woocommerce/components';
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
Expand All @@ -20,6 +19,7 @@ import { __ } from '@wordpress/i18n';
import './style.scss';
import DepositStatusChip from 'components/deposit-status-chip';
import { getDepositDate } from 'deposits/utils';
import { displayType } from 'deposits/strings';
import { CachedDeposit } from 'wcpay/types/deposits';
import { formatCurrency } from 'multi-currency/interface/functions';
import { getDetailsURL } from 'wcpay/components/details-link';
Expand Down Expand Up @@ -51,7 +51,10 @@ const RecentDepositsList: React.FC< RecentDepositsProps > = ( {
</Link>
</FlexItem>
<FlexItem className={ `${ tableClass }__cell` }>
<DepositStatusChip status={ deposit.status } />
<DepositStatusChip deposit={ deposit } />
</FlexItem>
<FlexItem className={ `${ tableClass }__cell` }>
{ displayType[ deposit.type ] }
</FlexItem>
<FlexItem className={ `${ tableClass }__cell` }>
{ formatCurrency( deposit.amount, deposit.currency ) }
Expand All @@ -69,6 +72,9 @@ const RecentDepositsList: React.FC< RecentDepositsProps > = ( {
<FlexItem className={ `${ tableClass }__cell` }>
{ __( 'Status', 'woocommerce-payments' ) }
</FlexItem>
<FlexItem className={ `${ tableClass }__cell` }>
{ __( 'Type', 'woocommerce-payments' ) }
</FlexItem>
<FlexItem className={ `${ tableClass }__cell` }>
{ __( 'Amount', 'woocommerce-payments' ) }
</FlexItem>
Expand Down
26 changes: 18 additions & 8 deletions client/components/deposits-overview/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
font-size: 13px;
align-items: center;
padding: 16px 0;
width: 20%;
text-align: center;

svg {
fill: $gray-900;
Expand All @@ -75,11 +77,25 @@
}

&:first-child {
width: 35%;
width: 40%;
text-align: left;
}

&:last-child {
margin-left: auto;
text-align: right;
}

@media screen and ( max-width: 605px ) {
width: 25%;

&:first-child {
width: 25%;
}

// Hide icon on mobile to save horizontal space.
svg {
display: none;
}
}
}
}
Expand All @@ -101,9 +117,3 @@
}
}
}

@media screen and ( max-width: 605px ) {
.wcpay-deposits-overview__table__cell:first-child {
width: 45%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ exports[`Deposits Overview information Component Renders 1`] = `
>
Status
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
data-wp-component="FlexItem"
>
Type
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
Expand Down Expand Up @@ -275,9 +282,16 @@ exports[`Deposits Overview information Component Renders 1`] = `
<span
class="chip chip-success"
>
Paid
Completed (paid)
</span>
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
data-wp-component="FlexItem"
>
Deposit
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
Expand Down Expand Up @@ -326,6 +340,13 @@ exports[`Deposits Overview information Component Renders 1`] = `
Pending
</span>
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
data-wp-component="FlexItem"
>
Withdrawal
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
Expand All @@ -334,6 +355,61 @@ exports[`Deposits Overview information Component Renders 1`] = `
$30.00
</div>
</div>
<div
class="components-flex wcpay-deposits-overview__table__row css-1giw1wa-View-Flex-sx-Base-sx-Items-ItemsRow em57xhy0"
data-wp-c16t="true"
data-wp-component="Flex"
>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
data-wp-component="FlexItem"
>
<svg
aria-hidden="true"
focusable="false"
height="17"
viewBox="0 0 24 24"
width="17"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z"
/>
</svg>
<a
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdeposits%2Fdetails&id=po_mock3"
>
January 4, 2020
</a>
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
data-wp-component="FlexItem"
>
<span
class="chip chip-success"
>
Completed (deducted)
</span>
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
data-wp-component="FlexItem"
>
Withdrawal
</div>
<div
class="components-flex-item wcpay-deposits-overview__table__cell css-mw3lhz-View-Item-sx-Base em57xhy0"
data-wp-c16t="true"
data-wp-component="FlexItem"
>
$40.00
</div>
</div>
</div>
<div
class="components-flex components-card__footer components-card-footer wcpay-deposits-overview__footer css-p1v47q-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-medium em57xhy0"
Expand Down
9 changes: 9 additions & 0 deletions client/components/deposits-overview/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ const mockDeposits = [
bankAccount: 'MOCK BANK •••• 1234 (USD)',
currency: 'USD',
} as CachedDeposit,
{
id: 'po_mock3',
date: '2020-01-04 17:46:02',
type: 'withdrawal',
amount: 4000,
status: 'paid',
bankAccount: 'MOCK BANK •••• 1234 (USD)',
currency: 'USD',
} as CachedDeposit,
];

// Creates a mock Overview object for the given currency code and balance amounts.
Expand Down
Loading
Loading