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

32 lines
933 B
JavaScript
Raw Normal View History

2023-06-13 20:59:12 +02:00
import { Button, Icon, Text, useToasts, 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-04-21 17:00:42 +02:00
export function PasswordChangeButton() {
2023-03-22 22:05:55 +01:00
const { formatMessage, labels, messages } = useMessages();
2023-06-13 20:59:12 +02:00
const { showToast } = useToasts();
2023-01-21 02:12:53 +01:00
const handleSave = () => {
showToast({ message: formatMessage(messages.saved), variant: 'success' });
};
return (
<>
2023-03-24 18:55:20 +01:00
<ModalTrigger>
2023-01-25 16:42:46 +01:00
<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-03-24 18:55:20 +01:00
<Modal title={formatMessage(labels.changePassword)}>
{close => <PasswordEditForm onSave={handleSave} onClose={close} />}
</Modal>
2023-01-25 16:42:46 +01:00
</ModalTrigger>
2023-01-21 02:12:53 +01:00
</>
);
}
2023-04-21 17:00:42 +02:00
export default PasswordChangeButton;