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

refactor(console): use nullable in form type (#452)

This commit is contained in:
Wang Sijie 2022-03-25 15:16:57 +08:00 committed by GitHub
parent b46cfd2bc3
commit 3f8cc6af69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
import { User } from '@logto/schemas';
import { Nullable } from '@silverhand/essentials';
import React, { useEffect, useState } from 'react';
import { useController, useForm } from 'react-hook-form';
import { toast } from 'react-hot-toast';
@ -31,12 +32,12 @@ import UserConnectors from './components/UserConnectors';
import * as styles from './index.module.scss';
type FormData = {
primaryEmail: string;
primaryPhone: string;
username: string;
name: string;
avatar: string;
roles: string;
primaryEmail: Nullable<string>;
primaryPhone: Nullable<string>;
username: Nullable<string>;
name: Nullable<string>;
avatar: Nullable<string>;
roles: Nullable<string>;
customData: string;
};
@ -61,11 +62,7 @@ const UserDetails = () => {
return;
}
reset({
primaryEmail: data.primaryEmail ?? '',
primaryPhone: data.primaryPhone ?? '',
username: data.username ?? '',
name: data.name ?? '',
avatar: data.avatar ?? '',
...data,
roles: data.roleNames.join(','),
customData: JSON.stringify(data.customData, null, 2),
});