This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove proptypes from payment-method-card and payment-method-error-bo… (
#9817) * proptype removal * updated payment-method-error-boundary.tsx --------- Co-authored-by: Niels Lange <[email protected]>
- Loading branch information
1 parent
cc55ca7
commit 6339f97
Showing
3 changed files
with
60 additions
and
75 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
68 changes: 0 additions & 68 deletions
68
assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-error-boundary.js
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-error-boundary.tsx
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,52 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useState } from '@wordpress/element'; | ||
import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings'; | ||
import { StoreNoticesContainer } from '@woocommerce/blocks-checkout'; | ||
import { noticeContexts } from '@woocommerce/base-context'; | ||
import { NoticeType } from '@woocommerce/types'; | ||
interface PaymentMethodErrorBoundaryProps { | ||
isEditor: boolean; | ||
children: React.ReactNode; | ||
} | ||
const PaymentMethodErrorBoundary = ( { | ||
isEditor, | ||
children, | ||
}: PaymentMethodErrorBoundaryProps ) => { | ||
const [ errorMessage ] = useState( '' ); | ||
const [ hasError ] = useState( false ); | ||
if ( hasError ) { | ||
let errorText = __( | ||
'We are experiencing difficulties with this payment method. Please contact us for assistance.', | ||
'woo-gutenberg-products-block' | ||
); | ||
if ( isEditor || CURRENT_USER_IS_ADMIN ) { | ||
if ( errorMessage ) { | ||
errorText = errorMessage; | ||
} else { | ||
errorText = __( | ||
"There was an error with this payment method. Please verify it's configured correctly.", | ||
'woo-gutenberg-products-block' | ||
); | ||
} | ||
} | ||
const notices: NoticeType[] = [ | ||
{ | ||
id: '0', | ||
content: errorText, | ||
isDismissible: false, | ||
status: 'error', | ||
}, | ||
]; | ||
return ( | ||
<StoreNoticesContainer | ||
additionalNotices={ notices } | ||
context={ noticeContexts.PAYMENTS } | ||
/> | ||
); | ||
} | ||
return <>{ children }</>; | ||
}; | ||
export default PaymentMethodErrorBoundary; |