umami/components/pages/settings/websites/WebsiteData.js

49 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-02-28 05:03:04 +01:00
import { Button, Modal, ModalTrigger, ActionForm } from 'react-basics';
2023-01-25 16:42:46 +01:00
import { useIntl } from 'react-intl';
import WebsiteDeleteForm from 'components/pages/settings/websites/WebsiteDeleteForm';
import WebsiteResetForm from 'components/pages/settings/websites/WebsiteResetForm';
import { labels, messages } from 'components/messages';
2023-02-28 05:03:04 +01:00
export default function WebsiteData({ websiteId, onSave }) {
2023-01-25 16:42:46 +01:00
const { formatMessage } = useIntl();
const handleReset = async () => {
onSave('reset');
};
const handleDelete = async () => {
onSave('delete');
};
return (
2023-02-28 05:03:04 +01:00
<>
<ActionForm
label={formatMessage(labels.resetWebsite)}
description={formatMessage(messages.resetWebsiteWarning)}
>
<ModalTrigger>
2023-02-28 05:03:04 +01:00
<Button variant="secondary">{formatMessage(labels.reset)}</Button>
<Modal title={formatMessage(labels.resetWebsite)}>
{close => (
<WebsiteResetForm websiteId={websiteId} onSave={handleReset} onClose={close} />
)}
</Modal>
</ModalTrigger>
2023-02-28 05:03:04 +01:00
</ActionForm>
<ActionForm
label={formatMessage(labels.deleteWebsite)}
description={formatMessage(messages.deleteWebsiteWarning)}
>
<ModalTrigger>
2023-02-28 05:03:04 +01:00
<Button variant="danger">Delete</Button>
<Modal title={formatMessage(labels.deleteWebsite)}>
{close => (
<WebsiteDeleteForm websiteId={websiteId} onSave={handleDelete} onClose={close} />
)}
</Modal>
</ModalTrigger>
2023-02-28 05:03:04 +01:00
</ActionForm>
</>
);
}