mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added dirty state to user detail modal (#17824)
refs https://github.com/TryGhost/Product/issues/3349 --- Improved user experience for editing user details in the admin settings. Added `dirty` state to track and handle unsaved changes in the `UserDetailModal` component.
This commit is contained in:
parent
44ae0dcbe1
commit
0b720c237c
1 changed files with 8 additions and 2 deletions
|
@ -424,14 +424,19 @@ const UserMenuTrigger = () => (
|
|||
const UserDetailModal:React.FC<UserDetailModalProps> = ({user}) => {
|
||||
const {updateRoute} = useRouting();
|
||||
const {ownerUser} = useStaffUsers();
|
||||
const [userData, setUserData] = useState(user);
|
||||
const [saveState, setSaveState] = useState('');
|
||||
const [userData, _setUserData] = useState(user);
|
||||
const [saveState, setSaveState] = useState<'' | 'unsaved' | 'saving' | 'saved'>('');
|
||||
const [errors, setErrors] = useState<{
|
||||
name?: string;
|
||||
email?: string;
|
||||
url?: string;
|
||||
}>({});
|
||||
|
||||
const setUserData = (newUserData: User | ((current: User) => User)) => {
|
||||
_setUserData(newUserData);
|
||||
setSaveState('unsaved');
|
||||
};
|
||||
|
||||
const mainModal = useModal();
|
||||
const {mutateAsync: uploadImage} = useUploadImage();
|
||||
const {mutateAsync: updateUser} = useEditUser();
|
||||
|
@ -645,6 +650,7 @@ const UserDetailModal:React.FC<UserDetailModalProps> = ({user}) => {
|
|||
return (
|
||||
<Modal
|
||||
afterClose={() => updateRoute('users')}
|
||||
dirty={saveState === 'unsaved'}
|
||||
okLabel={okLabel}
|
||||
size='lg'
|
||||
stickyFooter={true}
|
||||
|
|
Loading…
Reference in a new issue