refactor(web): remove typescript
This commit is contained in:
@@ -19,67 +19,52 @@ import InputLabel from '@mui/material/InputLabel';
|
||||
import OutlinedInput from '@mui/material/OutlinedInput';
|
||||
import FormControl from '@mui/material/FormControl';
|
||||
import Box from '@mui/material/Box';
|
||||
import type { IApp } from 'types';
|
||||
|
||||
import * as URLS from 'config/urls';
|
||||
import AppIcon from 'components/AppIcon';
|
||||
import { GET_APPS } from 'graphql/queries/get-apps';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
|
||||
function createConnectionOrFlow(appKey: string, supportsConnections = false) {
|
||||
function createConnectionOrFlow(appKey, supportsConnections = false) {
|
||||
if (!supportsConnections) {
|
||||
return URLS.CREATE_FLOW_WITH_APP(appKey);
|
||||
}
|
||||
|
||||
return URLS.APP_ADD_CONNECTION(appKey);
|
||||
}
|
||||
|
||||
type AddNewAppConnectionProps = {
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
export default function AddNewAppConnection(
|
||||
props: AddNewAppConnectionProps
|
||||
): React.ReactElement {
|
||||
export default function AddNewAppConnection(props) {
|
||||
const { onClose } = props;
|
||||
const theme = useTheme();
|
||||
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('sm'));
|
||||
const formatMessage = useFormatMessage();
|
||||
const [appName, setAppName] = React.useState<string | null>(null);
|
||||
const [appName, setAppName] = React.useState(null);
|
||||
const [loading, setLoading] = React.useState(false);
|
||||
const [getApps, { data }] = useLazyQuery(GET_APPS, {
|
||||
onCompleted: () => {
|
||||
setLoading(false);
|
||||
},
|
||||
});
|
||||
|
||||
const fetchData = React.useMemo(
|
||||
() => debounce((name) => getApps({ variables: { name } }), 300),
|
||||
[getApps]
|
||||
[getApps],
|
||||
);
|
||||
|
||||
React.useEffect(
|
||||
function fetchAppsOnAppNameChange() {
|
||||
setLoading(true);
|
||||
|
||||
fetchData(appName);
|
||||
},
|
||||
[fetchData, appName]
|
||||
[fetchData, appName],
|
||||
);
|
||||
|
||||
React.useEffect(function cancelDebounceOnUnmount() {
|
||||
return () => {
|
||||
fetchData.cancel();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={true}
|
||||
onClose={onClose}
|
||||
maxWidth="sm"
|
||||
fullWidth
|
||||
data-test="add-app-connection-dialog">
|
||||
data-test="add-app-connection-dialog"
|
||||
>
|
||||
<DialogTitle>{formatMessage('apps.addNewAppConnection')}</DialogTitle>
|
||||
|
||||
<Box px={3}>
|
||||
@@ -123,7 +108,7 @@ export default function AddNewAppConnection(
|
||||
)}
|
||||
|
||||
{!loading &&
|
||||
data?.getApps?.map((app: IApp) => (
|
||||
data?.getApps?.map((app) => (
|
||||
<ListItem disablePadding key={app.name} data-test="app-list-item">
|
||||
<ListItemButton
|
||||
component={Link}
|
Reference in New Issue
Block a user