-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a new page component for redirecting disputes => details: (#7310)
Co-authored-by: Rua Haszard <[email protected]> Co-authored-by: Eric Jinks <[email protected]>
- Loading branch information
1 parent
a10f4c0
commit 1e696f8
Showing
13 changed files
with
149 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
This work is part of a UI improvements to increase disputes response that is behind a feature flag. A changelog entry will be added to represent the work as a whole. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React, { useEffect } from 'react'; | ||
import { getHistory } from '@woocommerce/navigation'; | ||
import { Spinner, Icon, Flex, FlexItem } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import Page from 'components/page'; | ||
import { useDispute } from 'data/index'; | ||
import { Charge } from 'wcpay/types/charges'; | ||
import { getAdminUrl } from 'wcpay/utils'; | ||
|
||
import './style.scss'; | ||
import warning from 'wcpay/components/icons/warning'; | ||
|
||
const RedirectToTransactionDetails: React.FC< { query: { id: string } } > = ( { | ||
query: { id: disputeId }, | ||
} ) => { | ||
const { dispute, error, isLoading } = useDispute( disputeId ); | ||
|
||
useEffect( () => { | ||
if ( ! isLoading && dispute?.charge ) { | ||
// Dispute type allows charge as nested object or string ID, | ||
// so we have to hint we expect a Charge object here. | ||
const chargeObject = dispute.charge as Charge; | ||
const transactionDetailsUrl = getAdminUrl( { | ||
page: 'wc-admin', | ||
path: '/payments/transactions/details', | ||
id: chargeObject.payment_intent, | ||
transaction_id: chargeObject.balance_transaction, | ||
type: 'dispute', | ||
} ); | ||
getHistory().replace( transactionDetailsUrl ); | ||
} | ||
}, [ dispute, isLoading ] ); | ||
|
||
return ( | ||
<Page> | ||
<Flex | ||
direction="column" | ||
className="wcpay-dispute-detail-legacy-redirect" | ||
> | ||
{ error ? ( | ||
<> | ||
<FlexItem> | ||
<Icon icon={ warning } type="warning" size={ 32 } /> | ||
</FlexItem> | ||
<FlexItem> | ||
<div> | ||
<b>Error retrieving dispute</b> | ||
</div> | ||
<div>Please check your network and try again.</div> | ||
</FlexItem> | ||
</> | ||
) : ( | ||
<> | ||
<FlexItem> | ||
<Spinner /> | ||
</FlexItem> | ||
<FlexItem> | ||
<div> | ||
<b>One moment please</b> | ||
</div> | ||
<div>Redirecting to payment details…</div> | ||
</FlexItem> | ||
</> | ||
) } | ||
</Flex> | ||
</Page> | ||
); | ||
}; | ||
|
||
export default RedirectToTransactionDetails; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.wcpay-dispute-detail-legacy-redirect { | ||
// Shift the redirect spinner to approx center of viewport. | ||
top: 10vh; | ||
position: relative; | ||
|
||
.components-flex-item { | ||
text-align: center; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters