/* * @Author: ZhaoYing * @Date: 2026-02-02 15:09:47 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-02-02 15:51:54 */ /** * UserInfoModal Component * * A modal dialog that displays user profile information and security settings. * Includes basic user details and password change functionality. * Uses forwardRef to expose open/close methods to parent components. * * @component */ import { forwardRef, useImperativeHandle, useState, useRef } from 'react'; import { Button } from 'antd'; import { UnlockOutlined } from '@ant-design/icons'; import { useTranslation } from 'react-i18next'; import { useUser } from '@/store/user'; import RbModal from '@/components/RbModal' import { formatDateTime } from '@/utils/format'; import ResetPasswordModal from '@/views/UserManagement/components/ResetPasswordModal' import type { ResetPasswordModalRef } from '@/views/UserManagement/types' /** Interface for UserInfoModal ref methods exposed to parent components */ export interface UserInfoModalRef { /** Open the user info modal */ handleOpen: () => void; /** Close the user info modal */ handleClose: () => void; } /** User information modal component displaying user details and security settings */ const UserInfoModal = forwardRef((_props, ref) => { const { t } = useTranslation(); const resetPasswordModalRef = useRef(null) const { user } = useUser(); const [visible, setVisible] = useState(false); /** Close the modal */ const handleClose = () => { setVisible(false); }; /** Open the modal */ const handleOpen = () => { setVisible(true); }; /** Expose handleOpen and handleClose methods to parent component via ref */ useImperativeHandle(ref, () => ({ handleOpen, handleClose })); return ( {/* Basic Information Section */}
{t('header.basicInfo')}
{/* Username */}
{t('user.username')} {user.username}
{/* Email */}
{t('user.email')} {user.email}
{/* Role */}
{t('user.role')} {user.is_superuser ? t('user.superuser') : t('user.normalUser')}
{/* Created Date */}
{t('user.createdAt')} {formatDateTime(user.created_at, 'YYYY-MM-DD HH:mm:ss')}
{/* Security Settings Section */}
{t('header.securitySettings')}
{/* Password Change Card */}
{t('header.changePassword')}
{t('header.changePasswordDesc')}
); }); export default UserInfoModal;