feat: use existing change password wizard in preferences (#639)

This commit is contained in:
Gorjan Petrovski
2021-09-21 17:36:52 +02:00
committed by GitHub
parent e6e01d0f2c
commit 8464824c61

View File

@@ -6,14 +6,13 @@ import { HorizontalSeparator } from '@/components/shared/HorizontalSeparator';
import { dateToLocalizedString } from '@/utils'; import { dateToLocalizedString } from '@/utils';
import { useState } from 'preact/hooks'; import { useState } from 'preact/hooks';
import { ChangeEmail } from '@/preferences/panes/account/changeEmail'; import { ChangeEmail } from '@/preferences/panes/account/changeEmail';
import { ChangePassword } from '@/preferences/panes/account/changePassword'; import { PasswordWizardType } from '@/types';
type Props = { type Props = {
application: WebApplication; application: WebApplication;
}; };
export const Credentials = observer(({ application }: Props) => { export const Credentials = observer(({ application }: Props) => {
const [isChangePasswordDialogOpen, setIsChangePasswordDialogOpen] = useState(false);
const [isChangeEmailDialogOpen, setIsChangeEmailDialogOpen] = useState(false); const [isChangeEmailDialogOpen, setIsChangeEmailDialogOpen] = useState(false);
const user = application.getUser(); const user = application.getUser();
@@ -51,7 +50,7 @@ export const Credentials = observer(({ application }: Props) => {
type='normal' type='normal'
label='Change password' label='Change password'
onClick={() => { onClick={() => {
setIsChangePasswordDialogOpen(true); application.presentPasswordWizard(PasswordWizardType.ChangePassword);
}} }}
/> />
{isChangeEmailDialogOpen && ( {isChangeEmailDialogOpen && (
@@ -60,13 +59,6 @@ export const Credentials = observer(({ application }: Props) => {
application={application} application={application}
/> />
)} )}
{
isChangePasswordDialogOpen && (
<ChangePassword
onCloseDialog={() => setIsChangePasswordDialogOpen(false)}
application={application}
/>
)}
</PreferencesSegment> </PreferencesSegment>
</PreferencesGroup> </PreferencesGroup>
); );