mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
refactor(console): add loading state to confirm reset password form (#2779)
This commit is contained in:
parent
c92120b1c1
commit
0e9a214140
1 changed files with 5 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
import type { User } from '@logto/schemas';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import ConfirmModal from '@/components/ConfirmModal';
|
||||
|
@ -15,10 +16,13 @@ const ResetPasswordForm = ({ onClose, userId }: Props) => {
|
|||
keyPrefix: 'admin_console',
|
||||
});
|
||||
const api = useApi();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const onSubmit = async () => {
|
||||
const password = nanoid(8);
|
||||
setIsLoading(true);
|
||||
await api.patch(`/api/users/${userId}/password`, { json: { password } }).json<User>();
|
||||
setIsLoading(false);
|
||||
onClose?.(password);
|
||||
};
|
||||
|
||||
|
@ -26,6 +30,7 @@ const ResetPasswordForm = ({ onClose, userId }: Props) => {
|
|||
<ConfirmModal
|
||||
isOpen
|
||||
title="user_details.reset_password.title"
|
||||
isLoading={isLoading}
|
||||
onCancel={() => {
|
||||
onClose?.();
|
||||
}}
|
||||
|
|
Loading…
Add table
Reference in a new issue