0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-24 22:41:28 -05:00

fix(console): add default value for custom auth rules in protected app details (#5360)

This commit is contained in:
Charles Zhao 2024-02-01 10:51:31 +08:00 committed by GitHub
parent f53a14d7a8
commit bc127751b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,7 +6,7 @@ import {
} from '@logto/schemas';
import { cond } from '@silverhand/essentials';
import classNames from 'classnames';
import { type ChangeEvent, useState } from 'react';
import { type ChangeEvent, useState, useEffect } from 'react';
import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
import { Trans, useTranslation } from 'react-i18next';
import useSWR from 'swr';
@ -56,6 +56,7 @@ function ProtectedAppSettings({ data }: Props) {
control,
register,
getFieldState,
setValue,
formState: { errors },
} = useFormContext<ApplicationForm>();
@ -64,6 +65,12 @@ function ProtectedAppSettings({ data }: Props) {
name: 'protectedAppMetadata.pageRules',
});
useEffect(() => {
if (fields.length === 0) {
setValue('protectedAppMetadata.pageRules', [{ path: '' }]);
}
}, [fields.length, setValue]);
if (!data.protectedAppMetadata) {
return null;
}