umami/components/pages/settings/profile/PasswordChangeButton.js

30 lines
945 B
JavaScript
Raw Normal View History

2023-01-25 16:42:46 +01:00
import { useIntl } from 'react-intl';
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-01-25 16:42:46 +01:00
import { labels, messages } from 'components/messages';
2023-01-21 02:12:53 +01:00
2023-01-24 00:32:35 +01:00
export default function PasswordChangeButton() {
2023-01-21 02:12:53 +01:00
const { formatMessage } = useIntl();
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>
<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
</>
);
}