Skip to content

Commit

Permalink
Ran prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mxl-stripe committed Jul 31, 2024
1 parent 286bfa2 commit 7a6e4f3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 45 deletions.
104 changes: 60 additions & 44 deletions src/Components.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import {useCreateComponent} from './useCreateComponent';
import {useUpdateWithSetter} from './utils/useUpdateWithSetter';
import {CollectionOptions, FetchEphemeralKeyFunction} from './types';
import {LoadError, LoaderStart, NotificationCount, InstallState} from '@stripe/connect-js';
import {
LoadError,
LoaderStart,
NotificationCount,
InstallState,
} from '@stripe/connect-js';

export type CommonComponentProps = {
onLoaderStart: ({elementTagName}: LoaderStart) => void;
Expand Down Expand Up @@ -61,6 +66,22 @@ export const ConnectAppViewport = ({
return wrapper;
};

export const ConnectBalances = ({
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
const {wrapper, component: balances} = useCreateComponent('balances');

useUpdateWithSetter(balances, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
});
useUpdateWithSetter(balances, onLoadError, (comp, val) => {
comp.setOnLoadError(val);
});

return wrapper;
};

export const ConnectPayments = ({
onLoadError,
onLoaderStart,
Expand Down Expand Up @@ -93,6 +114,22 @@ export const ConnectPayouts = ({
return wrapper;
};

export const ConnectPayoutsList = ({
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
const {wrapper, component: payoutsList} = useCreateComponent('payouts-list');

useUpdateWithSetter(payoutsList, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
});
useUpdateWithSetter(payoutsList, onLoadError, (comp, val) => {
comp.setOnLoadError(val);
});

return wrapper;
};

export const ConnectPaymentDetails = ({
payment,
onClose,
Expand Down Expand Up @@ -173,7 +210,9 @@ export const ConnectPaymentMethodSettings = ({
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
const {wrapper, component: paymentMethodSettings} = useCreateComponent('payment-method-settings');
const {wrapper, component: paymentMethodSettings} = useCreateComponent(
'payment-method-settings'
);

useUpdateWithSetter(paymentMethodSettings, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
Expand Down Expand Up @@ -212,9 +251,10 @@ export const ConnectInstantPayouts = ({
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
const {wrapper, component: instantPayouts} = useCreateComponent('instant-payouts');
const {wrapper, component: instantPayouts} =
useCreateComponent('instant-payouts');

useUpdateWithSetter(instantPayouts, onLoaderStart, (comp, val) => {
useUpdateWithSetter(instantPayouts, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
});
useUpdateWithSetter(instantPayouts, onLoadError, (comp, val) => {
Expand Down Expand Up @@ -339,7 +379,6 @@ export const ConnectFinancialAccount = ({
comp.setOnLoadError(val);
});


return wrapper;
};

Expand All @@ -358,12 +397,20 @@ export const ConnectFinancialAccountTransactions = ({
financialAccount,
(comp, val) => comp.setFinancialAccount(val)
);
useUpdateWithSetter(financialAccountTransactionsComponent, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
});
useUpdateWithSetter(financialAccountTransactionsComponent, onLoadError, (comp, val) => {
comp.setOnLoadError(val);
});
useUpdateWithSetter(
financialAccountTransactionsComponent,
onLoaderStart,
(comp, val) => {
comp.setOnLoaderStart(val);
}
);
useUpdateWithSetter(
financialAccountTransactionsComponent,
onLoadError,
(comp, val) => {
comp.setOnLoadError(val);
}
);

return wrapper;
};
Expand All @@ -372,7 +419,8 @@ export const ConnectCapitalOverview = ({
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
const {wrapper, component: capitalOverview} = useCreateComponent('capital-overview');
const {wrapper, component: capitalOverview} =
useCreateComponent('capital-overview');

useUpdateWithSetter(capitalOverview, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
Expand Down Expand Up @@ -400,38 +448,6 @@ export const ConnectDocuments = ({
return wrapper;
};

export const ConnectPayoutsList = ({
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
const {wrapper, component: payoutsList} = useCreateComponent('payouts-list');

useUpdateWithSetter(payoutsList, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
});
useUpdateWithSetter(payoutsList, onLoadError, (comp, val) => {
comp.setOnLoadError(val);
});

return wrapper;
};

export const ConnectBalances = ({
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
const {wrapper, component: balances} = useCreateComponent('balances');

useUpdateWithSetter(balances, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
});
useUpdateWithSetter(balances, onLoadError, (comp, val) => {
comp.setOnLoadError(val);
});

return wrapper;
};

export const ConnectTaxRegistrations = ({
onLoadError,
onLoaderStart,
Expand Down
7 changes: 6 additions & 1 deletion src/utils/useUpdateWithSetter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React from 'react';
import {CollectionOptions, FetchEphemeralKeyFunction} from '../types';
import {LoadError, LoaderStart, InstallState, NotificationCount} from '@stripe/connect-js';
import {
LoadError,
LoaderStart,
InstallState,
NotificationCount,
} from '@stripe/connect-js';

export const useUpdateWithSetter = <
T extends HTMLElement,
Expand Down

0 comments on commit 7a6e4f3

Please sign in to comment.