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

Adds notice that deposits are paused to Deposits Listing screen #8347

Merged
merged 32 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a2347df
Added DepositFailureNotice to inform merchant that their payout bank …
Mar 5, 2024
22dfcb5
Added changelog
Mar 5, 2024
50a480e
Fix linting issues and tests
Mar 5, 2024
599d01e
Added tests for DepositFailureNotice
Mar 6, 2024
42c042e
Linting fixes
Mar 6, 2024
30d113f
Merge branch 'develop' into add/6294-deposit-account-error-notice
jessy-p Mar 6, 2024
f483236
Merge branch 'develop' into add/6294-deposit-account-error-notice
jessy-p Mar 6, 2024
5537a3f
Merge branch 'develop' into add/6294-deposit-account-error-notice
jessy-p Mar 6, 2024
fd1e1c4
Added DepositFailureNotice
Mar 7, 2024
5be2143
Added changelog
Mar 7, 2024
0b3a56b
Merge branch 'develop' into add/6294-deposit-account-error-notice
jessy-p Mar 7, 2024
e0edd1b
Fix linting errors
Mar 7, 2024
bdc0cc6
Merge branch 'add/6294-deposit-account-error-notice' into add/8332-de…
Mar 7, 2024
e95fa72
Merge branch 'develop' into add/6294-deposit-account-error-notice
jessy-p Mar 7, 2024
4612891
Made changes to hide the deposit schedule notice in case of an errored
Mar 7, 2024
76593c1
Made changes to hide the deposit timeline notice when
Mar 7, 2024
df7ac2b
Changed link in DepositFailureNotice to point to Stripe Account
Mar 7, 2024
b9d2ef9
Merge branch 'add/6294-deposit-account-error-notice' into add/8332-de…
jessy-p Mar 8, 2024
f17120f
Updated link to point to dashboard where merchant can update account
Mar 8, 2024
63bf836
Merge branch 'add/8332-deposits-list-failure-notice' of https://githu…
Mar 8, 2024
7d81838
Updated to reflect change in API
Mar 8, 2024
6736b46
Changed to ExternalLink and fixed tests.
Mar 14, 2024
58d5d5c
Merge branch 'develop' into add/6294-deposit-account-error-notice
jessy-p Mar 14, 2024
e7d6e62
Merge branch 'add/6294-deposit-account-error-notice' into add/8332-de…
jessy-p Mar 14, 2024
b9286db
Modified to ExternalLink and use default_external_accounts
Mar 14, 2024
6d349e5
Fixed formatting.
Mar 14, 2024
dfc814c
Merge branch 'develop' into add/8332-deposits-list-failure-notice
jessy-p Mar 14, 2024
f5a20f3
Merge branch 'develop' into add/8332-deposits-list-failure-notice
jessy-p Mar 15, 2024
b522cbc
Merge branch 'develop' into add/8332-deposits-list-failure-notice
jessy-p Mar 19, 2024
4375f79
Merge branch 'develop' into add/8332-deposits-list-failure-notice
naman03malhotra Mar 19, 2024
f09b14c
Moved dependency to correct block.
Mar 19, 2024
b5392c3
Merge branch 'develop' into add/8332-deposits-list-failure-notice
Mar 20, 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/add-8332-deposits-list-failure-notice
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Added a notice to the Deposits Listing screen when deposits are paused
50 changes: 48 additions & 2 deletions client/deposits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
*/
import React, { useState } from 'react';
import { useDispatch } from '@wordpress/data';
import { ExternalLink } from '@wordpress/components';

/**
* Internal dependencies.
*/
import Page from 'components/page';
naman03malhotra marked this conversation as resolved.
Show resolved Hide resolved
import interpolateComponents from '@automattic/interpolate-components';
import { __ } from '@wordpress/i18n';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we club the wordpress imports together?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason: #8347 (comment)

import { TestModeNotice } from 'components/test-mode-notice';
import BannerNotice from 'components/banner-notice';
import DepositSchedule from 'components/deposits-overview/deposit-schedule';
Expand Down Expand Up @@ -38,10 +41,24 @@ const useNextDepositNoticeState = () => {
};
};

const NextDepositNotice: React.FC = () => {
const useAccountStatus = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this PR can use a behavior test, wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Deposit Listing screen has no test file, will create a issue to add tests for this file, including this functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue here #8417

const {
overviews: { account },
} = useAllDepositsOverviews();

const hasErroredExternalAccount =
account?.default_external_accounts?.some(
( externalAccount ) => externalAccount.status === 'errored'
) ?? false;

return {
account,
hasErroredExternalAccount,
};
};

const NextDepositNotice: React.FC = () => {
const { account, hasErroredExternalAccount } = useAccountStatus();
const {
isNextDepositNoticeDismissed,
handleDismissNextDepositNotice,
Expand All @@ -63,7 +80,8 @@ const NextDepositNotice: React.FC = () => {
! hasCompletedWaitingPeriod ||
! account ||
isNextDepositNoticeDismissed ||
! hasScheduledDeposits
! hasScheduledDeposits ||
hasErroredExternalAccount
) {
return null;
}
Expand All @@ -79,6 +97,33 @@ const NextDepositNotice: React.FC = () => {
);
};

const DepositFailureNotice: React.FC = () => {
const { hasErroredExternalAccount } = useAccountStatus();

return hasErroredExternalAccount ? (
<BannerNotice
status="warning"
icon
className="deposit-failure-notice"
isDismissible={ false }
>
{ interpolateComponents( {
mixedString: __(
'Deposits are currently paused because a recent deposit failed. Please {{updateLink}}update your bank account details{{/updateLink}}.',
'woocommerce-payments'
),
components: {
updateLink: (
<ExternalLink
href={ wcpaySettings.accountStatus.accountLink }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Maybe we can move this outside the jsx block.

Why?
Deconstructing objects outside the JS block can improve the readability and maintainability of your code. By doing so, you can avoid cluttering the JSX block with lengthy code, making it easier to understand. Additionally, it allows you to reuse the deconstructed values throughout your code, reducing the likelihood of making errors or typos. By keeping your JSX block clean and organized, you can make sure that your code is easier to maintain and update over time.

const { accountLink } = wcpaySetting.accountStatus;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are not using any other field from wcpaySettings.accountStatus, I feel accessing wcpaySettings.accountStatus.accountLink just where it's used makes it easier to read. Would reconsider if we had multiple fields being used

/>
),
},
} ) }
</BannerNotice>
) : null;
};

const DepositsPage: React.FC = () => {
// pre-fetching the settings.
useSettings();
Expand All @@ -87,6 +132,7 @@ const DepositsPage: React.FC = () => {
<Page>
<TestModeNotice currentPage="deposits" />
<NextDepositNotice />
<DepositFailureNotice />
<DepositsList />
</Page>
);
Expand Down
Loading