1
+ import { FetchEphemeralKeyFunction } from './types' ;
1
2
import { useCreateComponent } from './useCreateComponent' ;
2
3
import { useUpdateWithSetter } from './utils/useUpdateWithSetter' ;
3
4
import {
4
5
LoadError ,
5
6
LoaderStart ,
6
7
NotificationCount ,
7
8
StepChange ,
8
- PaymentsListDefaultFilters
9
+ PaymentsListDefaultFilters ,
9
10
} from '@stripe/connect-js' ;
10
11
11
12
export type CommonComponentProps = {
@@ -17,7 +18,9 @@ export const ConnectPayments = ({
17
18
defaultFilters,
18
19
onLoadError,
19
20
onLoaderStart,
20
- } : { defaultFilters ?: PaymentsListDefaultFilters } & CommonComponentProps ) : JSX . Element => {
21
+ } : {
22
+ defaultFilters ?: PaymentsListDefaultFilters ;
23
+ } & CommonComponentProps ) : JSX . Element => {
21
24
const { wrapper, component : payments } = useCreateComponent ( 'payments' ) ;
22
25
23
26
useUpdateWithSetter ( payments , onLoaderStart , ( comp , val ) => {
@@ -187,6 +190,134 @@ export const ConnectNotificationBanner = ({
187
190
return wrapper ;
188
191
} ;
189
192
193
+ export const ConnectIssuingCard = ( {
194
+ defaultCard,
195
+ cardSwitching,
196
+ showSpendControls,
197
+ fetchEphemeralKey,
198
+ onLoadError,
199
+ onLoaderStart,
200
+ } : {
201
+ defaultCard ?: string ;
202
+ cardSwitching ?: boolean ;
203
+ showSpendControls ?: boolean ;
204
+ fetchEphemeralKey ?: FetchEphemeralKeyFunction ;
205
+ } & CommonComponentProps ) : JSX . Element => {
206
+ const { wrapper, component : issuingCard } = useCreateComponent ( 'issuing-card' ) ;
207
+
208
+ useUpdateWithSetter ( issuingCard , defaultCard , ( comp , val ) =>
209
+ comp . setDefaultCard ( val )
210
+ ) ;
211
+ useUpdateWithSetter ( issuingCard , cardSwitching , ( comp , val ) =>
212
+ comp . setCardSwitching ( val )
213
+ ) ;
214
+ useUpdateWithSetter ( issuingCard , showSpendControls , ( comp , val ) =>
215
+ comp . setShowSpendControls ( val )
216
+ ) ;
217
+ useUpdateWithSetter ( issuingCard , fetchEphemeralKey , ( comp , val ) =>
218
+ comp . setFetchEphemeralKey ( val )
219
+ ) ;
220
+ useUpdateWithSetter ( issuingCard , onLoaderStart , ( comp , val ) => {
221
+ comp . setOnLoaderStart ( val ) ;
222
+ } ) ;
223
+ useUpdateWithSetter ( issuingCard , onLoadError , ( comp , val ) => {
224
+ comp . setOnLoadError ( val ) ;
225
+ } ) ;
226
+
227
+ return wrapper ;
228
+ } ;
229
+
230
+ export const ConnectIssuingCardsList = ( {
231
+ showSpendControls,
232
+ issuingProgram,
233
+ fetchEphemeralKey,
234
+ onLoadError,
235
+ onLoaderStart,
236
+ } : {
237
+ showSpendControls ?: boolean ;
238
+ issuingProgram ?: string ;
239
+ fetchEphemeralKey ?: FetchEphemeralKeyFunction ;
240
+ } & CommonComponentProps ) : JSX . Element => {
241
+ const { wrapper, component : issuingCardsList } =
242
+ useCreateComponent ( 'issuing-cards-list' ) ;
243
+
244
+ useUpdateWithSetter ( issuingCardsList , showSpendControls , ( comp , val ) =>
245
+ comp . setShowSpendControls ( val )
246
+ ) ;
247
+ useUpdateWithSetter ( issuingCardsList , issuingProgram , ( comp , val ) =>
248
+ comp . setIssuingProgram ( val )
249
+ ) ;
250
+ useUpdateWithSetter ( issuingCardsList , fetchEphemeralKey , ( comp , val ) =>
251
+ comp . setFetchEphemeralKey ( val )
252
+ ) ;
253
+ useUpdateWithSetter ( issuingCardsList , onLoaderStart , ( comp , val ) => {
254
+ comp . setOnLoaderStart ( val ) ;
255
+ } ) ;
256
+ useUpdateWithSetter ( issuingCardsList , onLoadError , ( comp , val ) => {
257
+ comp . setOnLoadError ( val ) ;
258
+ } ) ;
259
+
260
+ return wrapper ;
261
+ } ;
262
+
263
+ export const ConnectFinancialAccount = ( {
264
+ financialAccount,
265
+ onLoadError,
266
+ onLoaderStart,
267
+ } : {
268
+ financialAccount : string ;
269
+ } & CommonComponentProps ) : JSX . Element => {
270
+ const { wrapper, component : financialAccountComponent } =
271
+ useCreateComponent ( 'financial-account' ) ;
272
+
273
+ useUpdateWithSetter (
274
+ financialAccountComponent ,
275
+ financialAccount ,
276
+ ( comp , val ) => comp . setFinancialAccount ( val )
277
+ ) ;
278
+ useUpdateWithSetter ( financialAccountComponent , onLoaderStart , ( comp , val ) => {
279
+ comp . setOnLoaderStart ( val ) ;
280
+ } ) ;
281
+ useUpdateWithSetter ( financialAccountComponent , onLoadError , ( comp , val ) => {
282
+ comp . setOnLoadError ( val ) ;
283
+ } ) ;
284
+
285
+ return wrapper ;
286
+ } ;
287
+
288
+ export const ConnectFinancialAccountTransactions = ( {
289
+ financialAccount,
290
+ onLoadError,
291
+ onLoaderStart,
292
+ } : {
293
+ financialAccount : string ;
294
+ } & CommonComponentProps ) : JSX . Element => {
295
+ const { wrapper, component : financialAccountTransactionsComponent } =
296
+ useCreateComponent ( 'financial-account-transactions' ) ;
297
+
298
+ useUpdateWithSetter (
299
+ financialAccountTransactionsComponent ,
300
+ financialAccount ,
301
+ ( comp , val ) => comp . setFinancialAccount ( val )
302
+ ) ;
303
+ useUpdateWithSetter (
304
+ financialAccountTransactionsComponent ,
305
+ onLoaderStart ,
306
+ ( comp , val ) => {
307
+ comp . setOnLoaderStart ( val ) ;
308
+ }
309
+ ) ;
310
+ useUpdateWithSetter (
311
+ financialAccountTransactionsComponent ,
312
+ onLoadError ,
313
+ ( comp , val ) => {
314
+ comp . setOnLoadError ( val ) ;
315
+ }
316
+ ) ;
317
+
318
+ return wrapper ;
319
+ } ;
320
+
190
321
export const ConnectDocuments = ( {
191
322
onLoadError,
192
323
onLoaderStart,
0 commit comments