Skip to content

Commit

Permalink
fix: interfaces of components
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeiroguilherme committed Oct 2, 2023
1 parent d9b0fba commit 9fce638
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/lib/src/components/ClickToPay/ClickToPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { TxVariants } from '../tx-variants';
export class ClickToPayElement extends UIElement<ClickToPayElementProps> {
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);
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/components/Donation/Donation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface DonationProps extends UIElementProps {
class DonationElement extends UIElement<DonationProps> {
public static type = TxVariants.donation;

constructor(props) {
constructor(props: DonationProps) {
super(props);
this.donate = this.donate.bind(this);
}
Expand Down
14 changes: 2 additions & 12 deletions packages/lib/src/components/Giftcard/Giftcard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<GiftCardProps> {
public static type = TxVariants.giftcard;

Expand Down
20 changes: 20 additions & 0 deletions packages/lib/src/components/Giftcard/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { UIElementProps } from '../types';
import { FunctionComponent } from 'preact';
import { GiftcardFieldsProps } from './components/types';

export interface GiftCardElementData {
paymentMethod: {
type: 'giftcard';
Expand All @@ -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<GiftcardFieldsProps>;
}
3 changes: 2 additions & 1 deletion packages/lib/src/components/MealVoucherFR/MealVoucherFR.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,7 +12,7 @@ export class MealVoucherFRElement extends GiftcardElement {
TxVariants.mealVoucher_FR_groupeup
];

constructor(props) {
constructor(props: GiftCardProps) {
super({
...props,
pinRequired: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import IssuerListContainer from '../helpers/IssuerListContainer';
import IssuerListContainer, { IssuerListContainerProps } from '../helpers/IssuerListContainer';
import { TxVariants } from '../tx-variants';

class OnlineBankingPL extends IssuerListContainer {
Expand All @@ -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 });
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/components/UIElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export abstract class UIElement<P extends UIElementProps = UIElementProps> 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.
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/src/components/helpers/IssuerListContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class IssuerListContainer extends UIElement<IssuerListContainerProps> {
showPaymentMethodItemImages: false
};

constructor(props?: IssuerListContainerProps) {
constructor(props: IssuerListContainerProps) {
super(props);

const getImage = props => this.resources.getImage(props);
Expand All @@ -62,7 +62,7 @@ class IssuerListContainer extends UIElement<IssuerListContainerProps> {
formatData(): IssuerListData {
return {
paymentMethod: {
type: this.constructor['type'],
type: this.type,
issuer: this.state?.data?.issuer
}
};
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit 9fce638

Please sign in to comment.