refactor(web): remove typescript
This commit is contained in:
@@ -6,39 +6,28 @@ import Paper from '@mui/material/Paper';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import LoadingButton from '@mui/lab/LoadingButton';
|
||||
import { useMutation } from '@apollo/client';
|
||||
|
||||
import { CREATE_APP_CONFIG } from 'graphql/mutations/create-app-config';
|
||||
import { UPDATE_APP_CONFIG } from 'graphql/mutations/update-app-config';
|
||||
|
||||
import Form from 'components/Form';
|
||||
import { Switch } from './style';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
|
||||
type AdminApplicationSettingsProps = {
|
||||
appKey: string;
|
||||
};
|
||||
|
||||
function AdminApplicationSettings(
|
||||
props: AdminApplicationSettingsProps
|
||||
): React.ReactElement {
|
||||
function AdminApplicationSettings(props) {
|
||||
const { appConfig, loading } = useAppConfig(props.appKey);
|
||||
const [createAppConfig, { loading: loadingCreateAppConfig }] = useMutation(
|
||||
CREATE_APP_CONFIG,
|
||||
{
|
||||
refetchQueries: ['GetAppConfig'],
|
||||
}
|
||||
},
|
||||
);
|
||||
const [updateAppConfig, { loading: loadingUpdateAppConfig }] = useMutation(
|
||||
UPDATE_APP_CONFIG,
|
||||
{
|
||||
refetchQueries: ['GetAppConfig'],
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const formatMessage = useFormatMessage();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
|
||||
const handleSubmit = async (values: any) => {
|
||||
const handleSubmit = async (values) => {
|
||||
try {
|
||||
if (!appConfig) {
|
||||
await createAppConfig({
|
||||
@@ -56,23 +45,21 @@ function AdminApplicationSettings(
|
||||
enqueueSnackbar(formatMessage('adminAppsSettings.successfullySaved'), {
|
||||
variant: 'success',
|
||||
SnackbarProps: {
|
||||
'data-test': 'snackbar-save-admin-apps-settings-success'
|
||||
}
|
||||
'data-test': 'snackbar-save-admin-apps-settings-success',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error('Failed while saving!');
|
||||
}
|
||||
};
|
||||
|
||||
const defaultValues = useMemo(
|
||||
() => ({
|
||||
allowCustomConnection: appConfig?.allowCustomConnection || false,
|
||||
shared: appConfig?.shared || false,
|
||||
disabled: appConfig?.disabled || false,
|
||||
}),
|
||||
[appConfig]
|
||||
[appConfig],
|
||||
);
|
||||
|
||||
return (
|
||||
<Form
|
||||
defaultValues={defaultValues}
|
||||
@@ -122,5 +109,4 @@ function AdminApplicationSettings(
|
||||
></Form>
|
||||
);
|
||||
}
|
||||
|
||||
export default AdminApplicationSettings;
|
@@ -1,6 +1,5 @@
|
||||
import { styled } from '@mui/material/styles';
|
||||
import SwitchBase from 'components/Switch';
|
||||
|
||||
export const Switch = styled(SwitchBase)`
|
||||
justify-content: space-between;
|
||||
margin: 0;
|
Reference in New Issue
Block a user