Skip to content

Commit f352edf

Browse files
committed
Use built-in mechanism to disable OpenInvoice when Pay pressed
1 parent 7991ada commit f352edf

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

packages/lib/src/components/internal/OpenInvoice/OpenInvoice.scss

+7
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@
2727
.adyen-checkout__open-invoice .adyen-checkout__field--consentCheckbox {
2828
margin-top: token(spacer-070);
2929
}
30+
31+
.adyen-checkout__open-invoice{
32+
&--loading{
33+
@include index.adyen-checkout__component--loading;
34+
}
35+
}
36+

packages/lib/src/components/internal/OpenInvoice/OpenInvoice.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Field from '../FormFields/Field';
2222
import FormInstruction from '../FormInstruction';
2323
import { ComponentMethodsRef } from '../UIElement/types';
2424
import useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';
25+
import classNames from 'classnames';
2526

2627
const consentCBErrorObj: GenericError = {
2728
isValid: false,
@@ -111,7 +112,12 @@ export default function OpenInvoice(props: OpenInvoiceProps) {
111112
setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));
112113
};
113114
return (
114-
<div className="adyen-checkout__open-invoice">
115+
<div
116+
className={classNames({
117+
'adyen-checkout__open-invoice': true,
118+
'adyen-checkout__open-invoice--loading': status === 'loading'
119+
})}
120+
>
115121
<FormInstruction />
116122

117123
{activeFieldsets.companyDetails && (

packages/lib/src/components/internal/UIElement/UIElement.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,17 @@ export abstract class UIElement<P extends UIElementProps = UIElementProps> exten
111111
return this;
112112
}
113113

114+
/**
115+
* elementRef is a ref to the subclass that extends UIElement e.g. Card.tsx
116+
*/
114117
public setElementStatus(status: UIElementStatus, props?: any): this {
115118
this.elementRef?.setStatus(status, props);
116119
return this;
117120
}
118121

122+
/**
123+
* componentRef is a ref to the primary component inside that subclass e.g. CardInput.tsx
124+
*/
119125
public setStatus(status: UIElementStatus, props?): this {
120126
if (this.componentRef?.setStatus) {
121127
this.componentRef.setStatus(status, props);

packages/lib/src/styles/mixins.scss

+4
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,7 @@ $adyen-checkout-media-query-l-min: 1024px;
140140
padding: 0;
141141
position: absolute;
142142
}
143+
144+
@mixin adyen-checkout__component--loading {
145+
pointer-events: none;
146+
}

0 commit comments

Comments
 (0)