diff --git a/packages/lib/src/components/ClickToPay/ClickToPay.tsx b/packages/lib/src/components/ClickToPay/ClickToPay.tsx index 395665fd95..f26e64e6d1 100644 --- a/packages/lib/src/components/ClickToPay/ClickToPay.tsx +++ b/packages/lib/src/components/ClickToPay/ClickToPay.tsx @@ -15,8 +15,8 @@ import { TxVariants } from '../tx-variants'; export class ClickToPayElement extends UIElement { public static type = TxVariants.clicktopay; - private clickToPayService: IClickToPayService | null; - private ctpConfiguration: ClickToPayConfiguration; + private readonly clickToPayService: IClickToPayService | null; + private readonly ctpConfiguration: ClickToPayConfiguration; constructor(props: ClickToPayElementProps) { super(props); diff --git a/packages/lib/src/components/Donation/Donation.tsx b/packages/lib/src/components/Donation/Donation.tsx index 478e94afa1..ad7234ca91 100644 --- a/packages/lib/src/components/Donation/Donation.tsx +++ b/packages/lib/src/components/Donation/Donation.tsx @@ -15,7 +15,7 @@ interface DonationProps extends UIElementProps { class DonationElement extends UIElement { public static type = TxVariants.donation; - constructor(props) { + constructor(props: DonationProps) { super(props); this.donate = this.donate.bind(this); } diff --git a/packages/lib/src/components/Giftcard/Giftcard.tsx b/packages/lib/src/components/Giftcard/Giftcard.tsx index ef77264bab..d814fc135a 100644 --- a/packages/lib/src/components/Giftcard/Giftcard.tsx +++ b/packages/lib/src/components/Giftcard/Giftcard.tsx @@ -5,20 +5,10 @@ import CoreProvider from '../../core/Context/CoreProvider'; import PayButton from '../internal/PayButton'; import AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError'; import { PaymentAmount } from '../../types'; -import { PaymentResponse, UIElementProps } from '../types'; -import { GiftCardElementData } from './types'; +import { PaymentResponse } from '../types'; +import { GiftCardElementData, GiftCardProps } from './types'; import { TxVariants } from '../tx-variants'; -// TODO: Fix these types -interface GiftCardProps extends UIElementProps { - brandsConfiguration?: any; - brand?: string; - onOrderCreated?(data): void; - onOrderRequest?(resolve, reject, data): void; - onBalanceCheck?(resolve, reject, data): void; - onRequiringConfirmation?(): void; -} - export class GiftcardElement extends UIElement { public static type = TxVariants.giftcard; diff --git a/packages/lib/src/components/Giftcard/types.ts b/packages/lib/src/components/Giftcard/types.ts index efa783e9e1..182ce5b2b5 100644 --- a/packages/lib/src/components/Giftcard/types.ts +++ b/packages/lib/src/components/Giftcard/types.ts @@ -1,3 +1,7 @@ +import { UIElementProps } from '../types'; +import { FunctionComponent } from 'preact'; +import { GiftcardFieldsProps } from './components/types'; + export interface GiftCardElementData { paymentMethod: { type: 'giftcard'; @@ -6,3 +10,19 @@ export interface GiftCardElementData { encryptedSecurityCode: string; }; } + +// TODO: Fix these types +export interface GiftCardProps extends UIElementProps { + pinRequired?: boolean; + expiryDateRequired?: boolean; + brandsConfiguration?: any; + brand?: string; + onOrderCreated?(data): void; + onOrderRequest?(resolve, reject, data): void; + onBalanceCheck?(resolve, reject, data): void; + onRequiringConfirmation?(): void; + /** + * @internal + */ + fieldsLayoutComponent?: FunctionComponent; +} diff --git a/packages/lib/src/components/MealVoucherFR/MealVoucherFR.tsx b/packages/lib/src/components/MealVoucherFR/MealVoucherFR.tsx index 140627e55a..467f6f1b85 100644 --- a/packages/lib/src/components/MealVoucherFR/MealVoucherFR.tsx +++ b/packages/lib/src/components/MealVoucherFR/MealVoucherFR.tsx @@ -1,6 +1,7 @@ import GiftcardElement from '../Giftcard/Giftcard'; import { MealVoucherFields } from './components/MealVoucherFields'; import { TxVariants } from '../tx-variants'; +import { GiftCardProps } from '../Giftcard/types'; export class MealVoucherFRElement extends GiftcardElement { public static type = TxVariants.mealVoucher_FR; @@ -11,7 +12,7 @@ export class MealVoucherFRElement extends GiftcardElement { TxVariants.mealVoucher_FR_groupeup ]; - constructor(props) { + constructor(props: GiftCardProps) { super({ ...props, pinRequired: true, diff --git a/packages/lib/src/components/OnlinebankingPL/OnlineBankingPL.tsx b/packages/lib/src/components/OnlinebankingPL/OnlineBankingPL.tsx index 1871ff9a0e..627408d1ee 100644 --- a/packages/lib/src/components/OnlinebankingPL/OnlineBankingPL.tsx +++ b/packages/lib/src/components/OnlinebankingPL/OnlineBankingPL.tsx @@ -1,4 +1,4 @@ -import IssuerListContainer from '../helpers/IssuerListContainer'; +import IssuerListContainer, { IssuerListContainerProps } from '../helpers/IssuerListContainer'; import { TxVariants } from '../tx-variants'; class OnlineBankingPL extends IssuerListContainer { @@ -14,7 +14,7 @@ class OnlineBankingPL extends IssuerListContainer { urls: [OnlineBankingPL.disclaimerUrlsMap.regulation, OnlineBankingPL.disclaimerUrlsMap.obligation] }; - constructor(props?) { + constructor(props: IssuerListContainerProps) { super({ ...props, termsAndConditions: OnlineBankingPL.termsAndConditions }); } } diff --git a/packages/lib/src/components/UIElement.tsx b/packages/lib/src/components/UIElement.tsx index d06f870a50..96c3556f20 100644 --- a/packages/lib/src/components/UIElement.tsx +++ b/packages/lib/src/components/UIElement.tsx @@ -27,7 +27,7 @@ export abstract class UIElement

exten */ public static txVariants: string[] = []; - constructor(props?: P) { + constructor(props: P) { super(props); // Only register UIElements that have the 'type' set. Drop-in for example does not have. diff --git a/packages/lib/src/components/helpers/IssuerListContainer.tsx b/packages/lib/src/components/helpers/IssuerListContainer.tsx index cd84d6d0c3..05fd1dd39b 100644 --- a/packages/lib/src/components/helpers/IssuerListContainer.tsx +++ b/packages/lib/src/components/helpers/IssuerListContainer.tsx @@ -36,7 +36,7 @@ class IssuerListContainer extends UIElement { showPaymentMethodItemImages: false }; - constructor(props?: IssuerListContainerProps) { + constructor(props: IssuerListContainerProps) { super(props); const getImage = props => this.resources.getImage(props); @@ -62,7 +62,7 @@ class IssuerListContainer extends UIElement { formatData(): IssuerListData { return { paymentMethod: { - type: this.constructor['type'], + type: this.type, issuer: this.state?.data?.issuer } }; diff --git a/yarn.lock b/yarn.lock index 0cdb148bfd..9234f304b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12317,7 +12317,7 @@ regenerate@^1.4.2: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== -regenerator-runtime@^0.13.11: +regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.9: version "0.13.11" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==