2023-01-28 06:53:13 +01:00
|
|
|
import { Button, Icon, Text, useToast, ModalTrigger, Modal } from 'react-basics';
|
2023-01-21 02:12:53 +01:00
|
|
|
import PasswordEditForm from 'components/pages/settings/profile/PasswordEditForm';
|
2023-01-31 06:44:07 +01:00
|
|
|
import Icons from 'components/icons';
|
2023-03-22 22:05:55 +01:00
|
|
|
import useMessages from 'hooks/useMessages';
|
2023-01-21 02:12:53 +01:00
|
|
|
|
2023-01-24 00:32:35 +01:00
|
|
|
export default function PasswordChangeButton() {
|
2023-03-22 22:05:55 +01:00
|
|
|
const { formatMessage, labels, messages } = useMessages();
|
2023-01-21 02:12:53 +01:00
|
|
|
const { toast, showToast } = useToast();
|
|
|
|
|
|
|
|
const handleSave = () => {
|
|
|
|
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{toast}
|
2023-01-25 16:42:46 +01:00
|
|
|
<ModalTrigger modalProps={{ title: formatMessage(labels.changePassword) }}>
|
|
|
|
<Button>
|
|
|
|
<Icon>
|
2023-01-31 06:44:07 +01:00
|
|
|
<Icons.Lock />
|
2023-01-25 16:42:46 +01:00
|
|
|
</Icon>
|
|
|
|
<Text>{formatMessage(labels.changePassword)}</Text>
|
|
|
|
</Button>
|
2023-01-28 06:53:13 +01:00
|
|
|
<Modal>{close => <PasswordEditForm onSave={handleSave} onClose={close} />}</Modal>
|
2023-01-25 16:42:46 +01:00
|
|
|
</ModalTrigger>
|
2023-01-21 02:12:53 +01:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|