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

31 lines
922 B
JavaScript
Raw Normal View History

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-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
</>
);
}