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

45 lines
1.5 KiB
JavaScript
Raw Normal View History

import { Button, Form, FormRow, Modal, ModalTrigger } 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';
export default function WebsiteReset({ websiteId, onSave }) {
2023-01-25 16:42:46 +01:00
const { formatMessage } = useIntl();
const handleReset = async () => {
onSave('reset');
};
const handleDelete = async () => {
onSave('delete');
};
return (
<Form>
2023-01-25 16:42:46 +01:00
<FormRow label={formatMessage(labels.resetWebsite)}>
<p>{formatMessage(messages.resetWebsiteWarning)}</p>
<ModalTrigger>
<Button>{formatMessage(labels.reset)}</Button>
<Modal title={formatMessage(labels.resetWebsite)}>
{close => (
<WebsiteResetForm websiteId={websiteId} onSave={handleReset} onClose={close} />
)}
</Modal>
</ModalTrigger>
</FormRow>
2023-01-25 16:42:46 +01:00
<FormRow label={formatMessage(labels.deleteWebsite)}>
<p>{formatMessage(messages.deleteWebsiteWarning)}</p>
<ModalTrigger>
<Button>Delete</Button>
<Modal title={formatMessage(labels.deleteWebsite)}>
{close => (
<WebsiteDeleteForm websiteId={websiteId} onSave={handleDelete} onClose={close} />
)}
</Modal>
</ModalTrigger>
</FormRow>
</Form>
);
}