diff --git a/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx b/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx index 121357f6e7..97d184dc51 100644 --- a/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx +++ b/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx @@ -1,5 +1,5 @@ import APIKeys from '../advanced/integrations/APIKeys'; -import Button from '../../../admin-x-ds/global/Button'; +import ChangePasswordForm from './users/ChangePasswordForm'; import ConfirmationModal from '../../../admin-x-ds/global/modal/ConfirmationModal'; import Heading from '../../../admin-x-ds/global/Heading'; import Icon from '../../../admin-x-ds/global/Icon'; @@ -9,7 +9,7 @@ import Menu, {MenuItem} from '../../../admin-x-ds/global/Menu'; import Modal from '../../../admin-x-ds/global/modal/Modal'; import NiceModal, {useModal} from '@ebay/nice-modal-react'; import Radio from '../../../admin-x-ds/global/form/Radio'; -import React, {useCallback, useEffect, useRef, useState} from 'react'; +import React, {useCallback, useEffect, useState} from 'react'; import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; import SettingGroupContent from '../../../admin-x-ds/settings/SettingGroupContent'; import TextField from '../../../admin-x-ds/global/form/TextField'; @@ -23,7 +23,7 @@ import validator from 'validator'; import {DetailsInputs} from './DetailsInputs'; import {HostLimitError, useLimiter} from '../../../hooks/useLimiter'; import {RoutingModalProps} from '../../providers/RoutingProvider'; -import {User, canAccessSettings, hasAdminAccess, isAdminUser, isOwnerUser, useDeleteUser, useEditUser, useMakeOwner, useUpdatePassword} from '../../../api/users'; +import {User, canAccessSettings, hasAdminAccess, isAdminUser, isOwnerUser, useDeleteUser, useEditUser, useMakeOwner} from '../../../api/users'; import {genStaffToken, getStaffToken} from '../../../api/staffToken'; import {getImageUrl, useUploadImage} from '../../../api/images'; import {getSettingValues} from '../../../api/settings'; @@ -254,139 +254,6 @@ const EmailNotifications: React.FC = ({user, setUserData}) => { ); }; -function passwordValidation({password, confirmPassword}: {password: string; confirmPassword: string}) { - const errors: { - newPassword?: string; - confirmNewPassword?: string; - } = {}; - if (password !== confirmPassword) { - errors.newPassword = 'Your new passwords do not match'; - errors.confirmNewPassword = 'Your new passwords do not match'; - } - if (password.length < 10) { - errors.newPassword = 'Password must be at least 10 characters'; - } - - //ToDo: add more validations - - return errors; -} - -const Password: React.FC = ({user}) => { - const [editPassword, setEditPassword] = useState(false); - const [newPassword, setNewPassword] = useState(''); - const [confirmNewPassword, setConfirmNewPassword] = useState(''); - const [saveState, setSaveState] = useState<'saving'|'saved'|'error'|''>(''); - const [errors, setErrors] = useState<{ - newPassword?: string; - confirmNewPassword?: string; - }>({}); - const newPasswordRef = useRef(null); - const confirmNewPasswordRef = useRef(null); - - const {mutateAsync: updatePassword} = useUpdatePassword(); - - useEffect(() => { - if (saveState === 'saved') { - setTimeout(() => { - setSaveState(''); - setEditPassword(false); - }, 2500); - } - }, [saveState]); - - const showPasswordInputs = () => { - setEditPassword(true); - }; - - const view = ( -