diff --git a/packages/web/src/components/AddNewAppConnection/index.tsx b/packages/web/src/components/AddNewAppConnection/index.tsx index b14745b9..8b6cd30d 100644 --- a/packages/web/src/components/AddNewAppConnection/index.tsx +++ b/packages/web/src/components/AddNewAppConnection/index.tsx @@ -31,13 +31,15 @@ function createConnectionOrFlow(appKey: string, supportsConnections = false) { } return URLS.APP_ADD_CONNECTION(appKey); -}; +} type AddNewAppConnectionProps = { onClose: () => void; }; -export default function AddNewAppConnection(props: AddNewAppConnectionProps): React.ReactElement { +export default function AddNewAppConnection( + props: AddNewAppConnectionProps +): React.ReactElement { const { onClose } = props; const theme = useTheme(); const matchSmallScreens = useMediaQuery(theme.breakpoints.down('sm')); @@ -45,31 +47,34 @@ export default function AddNewAppConnection(props: AddNewAppConnectionProps): Re const [appName, setAppName] = React.useState(null); const [loading, setLoading] = React.useState(false); const [getApps, { data }] = useLazyQuery(GET_APPS, { - onCompleted: () => { setLoading(false); }, + onCompleted: () => { + setLoading(false); + }, }); const fetchData = React.useMemo( - () => debounce((name) => getApps({ variables: { name }}), 300), + () => debounce((name) => getApps({ variables: { name } }), 300), [getApps] ); - React.useEffect(function fetchAppsOnAppNameChange() { - setLoading(true); + React.useEffect( + function fetchAppsOnAppNameChange() { + setLoading(true); - fetchData(appName); - }, [fetchData, appName]); + fetchData(appName); + }, + [fetchData, appName] + ); React.useEffect(function cancelDebounceOnUnmount() { return () => { fetchData.cancel(); - } + }; }, []); return ( - - {formatMessage('apps.addNewAppConnection')} - + {formatMessage('apps.addNewAppConnection')} - + {formatMessage('apps.searchApp')} @@ -91,7 +94,9 @@ export default function AddNewAppConnection(props: AddNewAppConnectionProps): Re onChange={(event) => setAppName(event.target.value)} endAdornment={ - theme.palette.primary.main }} /> + theme.palette.primary.main }} + /> } label={formatMessage('apps.searchApp')} @@ -100,21 +105,36 @@ export default function AddNewAppConnection(props: AddNewAppConnectionProps): Re - {loading && } + {loading && ( + + )} - {!loading && data?.getApps?.map((app: IApp) => ( - - - - - + {!loading && + data?.getApps?.map((app: IApp) => ( + + + + + - theme.palette.text.primary } }} /> - - - ))} + theme.palette.text.primary }, + }} + /> + + + ))} ); -}; +}