umami/components/pages/settings/users/UserAddButton.js

28 lines
701 B
JavaScript
Raw Normal View History

import { Button, Icon, Text, Modal, Icons, ModalTrigger } from 'react-basics';
2023-01-24 00:32:35 +01:00
import UserAddForm from './UserAddForm';
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 UserAddButton({ onSave }) {
2023-03-22 22:05:55 +01:00
const { formatMessage, labels } = useMessages();
2023-01-21 02:12:53 +01:00
const handleSave = () => {
2023-01-25 16:42:46 +01:00
onSave();
2023-01-21 02:12:53 +01:00
};
return (
<ModalTrigger>
<Button variant="primary">
2023-01-21 02:12:53 +01:00
<Icon>
<Icons.Plus />
2023-01-21 02:12:53 +01:00
</Icon>
2023-01-25 16:42:46 +01:00
<Text>{formatMessage(labels.createUser)}</Text>
2023-01-21 02:12:53 +01:00
</Button>
<Modal title={formatMessage(labels.createUser)}>
{close => <UserAddForm onSave={handleSave} onClose={close} />}
</Modal>
</ModalTrigger>
2023-01-21 02:12:53 +01:00
);
}
2023-04-21 17:00:42 +02:00
export default UserAddButton;