@@ -6,13 +6,12 @@ import { useCustomize } from "../hooks/customization-context";
66import type { BaseReactSelectProps } from "../hooks/customization-context" ;
77import { useMemo } from "react" ;
88import type { CSSProperties } from "react" ;
9-
109import type { OptionProps } from "react-select" ;
11- import {
10+ import type {
1211 AppResponse , ConfigurablePropApp ,
1312} from "@pipedream/sdk" ;
1413
15- const BaseOption = ( props : OptionProps < any > ) => {
14+ const BaseOption = ( props : OptionProps < AppResponse > ) => {
1615 // const imgSrc =
1716 // props.data.img_src ?? `https://pipedream.com/s.v0/${props.data.id}/logo/48`
1817 return (
@@ -56,7 +55,7 @@ export function ControlApp({ app }: ControlAppProps) {
5655 Option : BaseOption ,
5756 } ,
5857 styles : {
59- control : ( base : { } ) => ( {
58+ control : ( base ) => ( {
6059 ...base ,
6160 gridArea : "control" ,
6261 boxShadow : theme . boxShadow . input ,
@@ -122,51 +121,51 @@ export function ControlApp({ app }: ControlAppProps) {
122121 app,
123122 ...formFieldCtx ,
124123 } ) } >
125- { isLoadingAccounts ? (
124+ { isLoadingAccounts ?
126125 `Loading ${ app . name } accounts...`
127- ) : accounts . length ? (
128- < Select
129- instanceId = { id }
130- value = { selectValue }
131- options = { [
132- ...accounts ,
133- {
134- id : "_new" ,
135- name : `Connect new ${ app . name } account...` ,
136- } ,
137- ] }
138- { ...selectProps }
139- required = { true }
140- placeholder = { `Select ${ app . name } account...` }
141- isLoading = { isLoadingAccounts }
142- isClearable = { true }
143- isSearchable = { true }
144- getOptionLabel = { ( a ) => a . name }
145- getOptionValue = { ( a ) => a . id }
146- onChange = { ( a ) => {
147- if ( a ) {
148- if ( a . id === "_new" ) {
126+ : accounts . length ?
127+ < Select
128+ instanceId = { id }
129+ value = { selectValue }
130+ options = { [
131+ ...accounts ,
132+ {
133+ id : "_new" ,
134+ name : `Connect new ${ app . name } account...` ,
135+ } ,
136+ ] }
137+ { ...selectProps }
138+ required = { true }
139+ placeholder = { `Select ${ app . name } account...` }
140+ isLoading = { isLoadingAccounts }
141+ isClearable = { true }
142+ isSearchable = { true }
143+ getOptionLabel = { ( a ) => a . name }
144+ getOptionValue = { ( a ) => a . id }
145+ onChange = { ( a ) => {
146+ if ( a ) {
147+ if ( a . id === "_new" ) {
149148 // start connect account and then select it, etc.
150149 // TODO unset / put in loading state
151- startConnectAccount ( ) ;
150+ startConnectAccount ( ) ;
151+ } else {
152+ onChange ( {
153+ authProvisionId : a . id ,
154+ } ) ;
155+ }
152156 } else {
153- onChange ( {
154- authProvisionId : a . id ,
155- } ) ;
157+ onChange ( undefined ) ;
156158 }
157- } else {
158- onChange ( undefined ) ;
159- }
160- } }
161- />
162- ) : (
163- < button type = "button" { ...getProps ( "connectButton" , baseStylesConnectButton , {
164- app,
165- ...formFieldCtx ,
166- } ) } onClick = { ( ) => startConnectAccount ( ) } >
159+ } }
160+ />
161+ :
162+ < button type = "button" { ...getProps ( "connectButton" , baseStylesConnectButton , {
163+ app,
164+ ...formFieldCtx ,
165+ } ) } onClick = { ( ) => startConnectAccount ( ) } >
167166 Connect { app . name }
168- </ button >
169- ) }
167+ </ button >
168+ }
170169 </ div >
171170 ) ;
172171}
0 commit comments