mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(console): set RHF default value (#4027)
This commit is contained in:
parent
2c21832793
commit
c774107980
1 changed files with 10 additions and 3 deletions
|
@ -16,6 +16,12 @@ import ProfileForm from './ProfileForm';
|
|||
import * as styles from './index.module.scss';
|
||||
import { type TenantSettingsForm } from './types.js';
|
||||
|
||||
const tenantProfileToForm = (tenant?: TenantInfo): TenantSettingsForm => {
|
||||
return {
|
||||
profile: { name: tenant?.name ?? 'My project', tag: tenant?.tag ?? TenantTag.Development },
|
||||
};
|
||||
};
|
||||
|
||||
function TenantBasicSettings() {
|
||||
const {
|
||||
api: cloudApi,
|
||||
|
@ -36,7 +42,9 @@ function TenantBasicSettings() {
|
|||
}
|
||||
}, [requestError]);
|
||||
|
||||
const methods = useForm<TenantSettingsForm>();
|
||||
const methods = useForm<TenantSettingsForm>({
|
||||
defaultValues: tenantProfileToForm(currentTenant),
|
||||
});
|
||||
const {
|
||||
watch,
|
||||
reset,
|
||||
|
@ -45,8 +53,7 @@ function TenantBasicSettings() {
|
|||
} = methods;
|
||||
|
||||
useEffect(() => {
|
||||
const { name, tag } = currentTenant ?? { name: 'My project', tag: TenantTag.Development };
|
||||
reset({ profile: { name, tag } });
|
||||
reset(tenantProfileToForm(currentTenant));
|
||||
}, [currentTenant, reset]);
|
||||
|
||||
const saveData = async (data: { name?: string; tag?: TenantTag }) => {
|
||||
|
|
Loading…
Reference in a new issue