0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(console): improve enterprise sso details page codes

This commit is contained in:
Xiao Yijun 2024-01-23 15:17:49 +08:00
parent 42e9513ca1
commit 9b58afa317
No known key found for this signature in database
GPG key ID: 6F648FC1262DB420
2 changed files with 8 additions and 10 deletions

View file

@ -2,8 +2,7 @@ import { SsoProviderName, type RequestErrorBody } from '@logto/schemas';
import { conditional, type Optional } from '@silverhand/essentials';
import cleanDeep from 'clean-deep';
import { HTTPError } from 'ky';
import { useEffect } from 'react';
import { useForm, FormProvider, type Path } from 'react-hook-form';
import { useForm, FormProvider, type Path, type DeepPartial } from 'react-hook-form';
import { toast } from 'react-hot-toast';
import { useTranslation } from 'react-i18next';
@ -42,7 +41,11 @@ function Connection<T extends SsoProviderName>({ isDeleted, data, onUpdated }: P
const api = useApi({ hideErrorToast: true });
const methods = useForm<GuideFormType<T>>();
const methods = useForm<GuideFormType<T>>({
// Make typescript happy
// eslint-disable-next-line no-restricted-syntax
defaultValues: config as DeepPartial<GuideFormType<T>>,
});
const {
watch,
@ -52,10 +55,6 @@ function Connection<T extends SsoProviderName>({ isDeleted, data, onUpdated }: P
reset,
} = methods;
useEffect(() => {
reset(config);
}, [config, reset]);
const onSubmit = handleSubmit(
trySubmitSafe(async (formData) => {
if (isSubmitting) {

View file

@ -11,7 +11,6 @@ import Delete from '@/assets/icons/delete.svg';
import File from '@/assets/icons/file.svg';
import DetailsPage from '@/components/DetailsPage';
import DetailsPageHeader from '@/components/DetailsPage/DetailsPageHeader';
import Skeleton from '@/components/DetailsPage/Skeleton';
import Drawer from '@/components/Drawer';
import PageMeta from '@/components/PageMeta';
import { EnterpriseSsoDetailsTabs } from '@/consts';
@ -101,14 +100,14 @@ function EnterpriseSsoConnectorDetails<T extends SsoProviderName>() {
<DetailsPage
backLink={enterpriseSsoPathname}
backLinkTitle="enterprise_sso_details.back_to_sso_connectors"
isLoading={isLoading}
error={requestError}
onRetry={() => {
void mutate();
}}
>
<PageMeta titleKey="enterprise_sso_details.page_title" />
{isLoading && <Skeleton />}
{!isLoading && ssoConnector && (
{ssoConnector && (
<>
<DetailsPageHeader
icon={