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,31 +1,18 @@
import React, { useCallback, useMemo } from 'react';
import { useParams } from 'react-router-dom';
import type { IApp } from 'types';
import { FieldValues, SubmitHandler } from 'react-hook-form';
import { useMutation } from '@apollo/client';
import { UPDATE_APP_AUTH_CLIENT } from 'graphql/mutations/update-app-auth-client';
import useAppAuthClient from 'hooks/useAppAuthClient.ee';
import useFormatMessage from 'hooks/useFormatMessage';
import AdminApplicationAuthClientDialog from 'components/AdminApplicationAuthClientDialog';
type AdminApplicationUpdateAuthClientProps = {
application: IApp;
onClose: () => void;
};
export default function AdminApplicationUpdateAuthClient(
props: AdminApplicationUpdateAuthClientProps
): React.ReactElement {
export default function AdminApplicationUpdateAuthClient(props) {
const { application, onClose } = props;
const { auth } = application;
const authFields = auth?.fields?.map((field) => ({
...field,
required: false,
}));
const formatMessage = useFormatMessage();
const { clientId } = useParams();
const { appAuthClient, loading: loadingAuthClient } =
useAppAuthClient(clientId);
@@ -34,8 +21,7 @@ export default function AdminApplicationUpdateAuthClient(
refetchQueries: ['GetAppAuthClients'],
context: { autoSnackbar: false },
});
const submitHandler: SubmitHandler<FieldValues> = async (values) => {
const submitHandler = async (values) => {
if (!appAuthClient) {
return;
}
@@ -52,14 +38,11 @@ export default function AdminApplicationUpdateAuthClient(
});
onClose();
};
const getAuthFieldsDefaultValues = useCallback(() => {
if (!authFields) {
return {};
}
const defaultValues: {
[key: string]: any;
} = {};
const defaultValues = {};
authFields.forEach((field) => {
if (field.value || field.type !== 'string') {
defaultValues[field.key] = field.value;
@@ -69,16 +52,14 @@ export default function AdminApplicationUpdateAuthClient(
});
return defaultValues;
}, [auth?.fields]);
const defaultValues = useMemo(
() => ({
name: appAuthClient?.name || '',
active: appAuthClient?.active || false,
...getAuthFieldsDefaultValues(),
}),
[appAuthClient, getAuthFieldsDefaultValues]
[appAuthClient, getAuthFieldsDefaultValues],
);
return (
<AdminApplicationAuthClientDialog
onClose={onClose}