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

fix(console): should reset the form every time close CreateTenantModal (#4244)

This commit is contained in:
Darcy Ye 2023-07-26 10:05:04 +08:00 committed by GitHub
parent 199e747781
commit 605e2b2a81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,8 +49,10 @@ function CreateTenantModal({ isOpen, onClose, skipPlanSelection = false }: Props
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const [tenantData, setTenantData] = useState<CreateTenantData>();
const theme = useTheme();
const defaultValues = { tag: TenantTag.Development };
const methods = useForm<CreateTenantData>({
defaultValues: { tag: TenantTag.Development },
defaultValues,
});
const {
@ -67,7 +69,6 @@ function CreateTenantModal({ isOpen, onClose, skipPlanSelection = false }: Props
void trySafe(async () => {
const { name, tag } = data;
const newTenant = await cloudApi.post('/api/tenants', { body: { name, tag } });
reset();
onClose(newTenant);
});
};
@ -85,6 +86,9 @@ function CreateTenantModal({ isOpen, onClose, skipPlanSelection = false }: Props
isOpen={isOpen}
className={modalStyles.content}
overlayClassName={modalStyles.overlay}
onAfterClose={() => {
reset(defaultValues);
}}
onRequestClose={() => {
onClose();
}}