refactor(web): remove typescript

This commit is contained in:
Ali BARIN
2024-02-27 15:23:23 +00:00
parent 636870a075
commit b3ae2d2748
337 changed files with 2067 additions and 4997 deletions

View File

@@ -1,24 +1,11 @@
import React, { useCallback, useMemo } from 'react';
import type { IApp } from 'types';
import { FieldValues, SubmitHandler } from 'react-hook-form';
import { useMutation } from '@apollo/client';
import { CREATE_APP_CONFIG } from 'graphql/mutations/create-app-config';
import { CREATE_APP_AUTH_CLIENT } from 'graphql/mutations/create-app-auth-client';
import useAppConfig from 'hooks/useAppConfig.ee';
import useFormatMessage from 'hooks/useFormatMessage';
import AdminApplicationAuthClientDialog from 'components/AdminApplicationAuthClientDialog';
type AdminApplicationCreateAuthClientProps = {
appKey: string;
application: IApp;
onClose: () => void;
};
export default function AdminApplicationCreateAuthClient(
props: AdminApplicationCreateAuthClientProps
): React.ReactElement {
export default function AdminApplicationCreateAuthClient(props) {
const { appKey, application, onClose } = props;
const { auth } = application;
const formatMessage = useFormatMessage();
@@ -37,10 +24,8 @@ export default function AdminApplicationCreateAuthClient(
refetchQueries: ['GetAppAuthClients'],
context: { autoSnackbar: false },
});
const submitHandler: SubmitHandler<FieldValues> = async (values) => {
const submitHandler = async (values) => {
let appConfigId = appConfig?.id;
if (!appConfigId) {
const { data: appConfigData } = await createAppConfig({
variables: {
@@ -54,9 +39,7 @@ export default function AdminApplicationCreateAuthClient(
});
appConfigId = appConfigData.createAppConfig.id;
}
const { name, active, ...formattedAuthDefaults } = values;
await createAppAuthClient({
variables: {
input: {
@@ -67,17 +50,13 @@ export default function AdminApplicationCreateAuthClient(
},
},
});
onClose();
};
const getAuthFieldsDefaultValues = useCallback(() => {
if (!auth?.fields) {
return {};
}
const defaultValues: {
[key: string]: any;
} = {};
const defaultValues = {};
auth.fields.forEach((field) => {
if (field.value || field.type !== 'string') {
defaultValues[field.key] = field.value;
@@ -87,16 +66,14 @@ export default function AdminApplicationCreateAuthClient(
});
return defaultValues;
}, [auth?.fields]);
const defaultValues = useMemo(
() => ({
name: '',
active: false,
...getAuthFieldsDefaultValues(),
}),
[getAuthFieldsDefaultValues]
[getAuthFieldsDefaultValues],
);
return (
<AdminApplicationAuthClientDialog
onClose={onClose}