-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) O3-3423: Allow user to change password (#1045)
- Loading branch information
1 parent
ecd896c
commit 5fa6ce5
Showing
6 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
25 changes: 25 additions & 0 deletions
25
packages/apps/esm-login-app/src/change-password/change-password.extension.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { useCallback } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { UserAvatarIcon, navigate, showModal, useSession } from '@openmrs/esm-framework'; | ||
import { Button, SwitcherItem } from '@carbon/react'; | ||
import styles from './change-password.scss'; | ||
|
||
const ChangePasswordLink: React.FC = () => { | ||
const { t } = useTranslation(); | ||
|
||
const launchChangePasswordModal = useCallback(() => showModal('change-password-modal'), []); | ||
|
||
return ( | ||
<SwitcherItem aria-label="Change Password" className={styles.panelItemContainer}> | ||
<div> | ||
<UserAvatarIcon size={20} /> | ||
<p>Password</p> | ||
</div> | ||
<Button kind="ghost" onClick={launchChangePasswordModal}> | ||
{t('change', 'Change')} | ||
</Button> | ||
</SwitcherItem> | ||
); | ||
}; | ||
|
||
export default ChangePasswordLink; |
57 changes: 57 additions & 0 deletions
57
packages/apps/esm-login-app/src/change-password/change-password.modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { type ChangeEvent, useCallback, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Button, InlineLoading, ModalBody, ModalFooter, ModalHeader } from '@carbon/react'; | ||
import styles from './change-password-modal.scss'; | ||
import { Form, PasswordInput } from '@carbon/react'; | ||
|
||
interface ChangePasswordModalProps { | ||
close(): void; | ||
} | ||
|
||
export default function ChangeLanguageModal({ close }: ChangePasswordModalProps) { | ||
const { t } = useTranslation(); | ||
const [isChangingPassword, setIsChangingPassword] = useState(false); | ||
const [oldPassword, setOldPassword] = useState<string>(); | ||
const [newPassword, setNewPassword] = useState<string>(); | ||
const [confirmPassword, setConfirmPassword] = useState<string>(); | ||
|
||
const handleSubmit = useCallback(() => { | ||
setIsChangingPassword(true); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<ModalHeader closeModal={close} title={t('changePassword', 'Change password')} /> | ||
<ModalBody> | ||
<div className={styles.languageOptionsContainer}> | ||
<Form> | ||
<PasswordInput | ||
onChange={(event: ChangeEvent) => setOldPassword(event.target.nodeValue)} | ||
labelText={t('oldPassword', 'Old Password')} | ||
/> | ||
<PasswordInput | ||
onChange={(event: ChangeEvent) => setNewPassword(event.target.nodeValue)} | ||
labelText={t('newPassword', 'New Password')} | ||
/> | ||
<PasswordInput | ||
onChange={(event: ChangeEvent) => setConfirmPassword(event.target.nodeValue)} | ||
labelText={t('confirmPassword', 'Confirm New Password')} | ||
/> | ||
</Form> | ||
</div> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button kind="secondary" onClick={close}> | ||
{t('cancel', 'Cancel')} | ||
</Button> | ||
<Button className={styles.submitButton} disabled={isChangingPassword} type="submit" onClick={handleSubmit}> | ||
{isChangingPassword ? ( | ||
<InlineLoading description={t('changingLanguage', 'Changing password') + '...'} /> | ||
) : ( | ||
<span>{t('change', 'Change')}</span> | ||
)} | ||
</Button> | ||
</ModalFooter> | ||
</> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/apps/esm-login-app/src/change-password/change-password.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.panelItemContainer a { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
.panelItemContainer div { | ||
display: flex; | ||
align-items: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters