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

fix(console): close modal on tab changed on user details page (#2750)

This commit is contained in:
Xiao Yijun 2022-12-29 13:44:37 +08:00 committed by GitHub
parent aaf92a6ef5
commit b7882d481e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
import type { User } from '@logto/schemas'; import type { User } from '@logto/schemas';
import classNames from 'classnames'; import classNames from 'classnames';
import { useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { toast } from 'react-hot-toast'; import { toast } from 'react-hot-toast';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import ReactModal from 'react-modal'; import ReactModal from 'react-modal';
@ -32,8 +32,8 @@ import * as styles from './index.module.scss';
import { userDetailsParser } from './utils'; import { userDetailsParser } from './utils';
const UserDetails = () => { const UserDetails = () => {
const location = useLocation(); const { pathname } = useLocation();
const isLogs = location.pathname.endsWith('/logs'); const isLogs = pathname.endsWith('/logs');
const { userId } = useParams(); const { userId } = useParams();
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const [isDeleteFormOpen, setIsDeleteFormOpen] = useState(false); const [isDeleteFormOpen, setIsDeleteFormOpen] = useState(false);
@ -55,6 +55,11 @@ const UserDetails = () => {
return userDetailsParser.toLocalForm(data); return userDetailsParser.toLocalForm(data);
}, [data]); }, [data]);
useEffect(() => {
setIsDeleteFormOpen(false);
setIsResetPasswordFormOpen(false);
}, [pathname]);
const onDelete = async () => { const onDelete = async () => {
if (!data || isDeleting) { if (!data || isDeleting) {
return; return;