mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 09:35:36 +01:00
More refactoring, cleaned up icons, nav buttons, add messages.
This commit is contained in:
parent
4b1013c8c6
commit
5f15ad0807
68 changed files with 391 additions and 790 deletions
|
|
@ -1,6 +1,4 @@
|
|||
import { useRouter } from 'next/router';
|
||||
import { useState } from 'react';
|
||||
import { Button, Form, FormRow, Modal } from 'react-basics';
|
||||
import { Button, Form, FormRow, Modal, ModalTrigger } from 'react-basics';
|
||||
import { useIntl } from 'react-intl';
|
||||
import WebsiteDeleteForm from 'components/pages/settings/websites/WebsiteDeleteForm';
|
||||
import WebsiteResetForm from 'components/pages/settings/websites/WebsiteResetForm';
|
||||
|
|
@ -8,43 +6,39 @@ import { labels, messages } from 'components/messages';
|
|||
|
||||
export default function WebsiteReset({ websiteId, onSave }) {
|
||||
const { formatMessage } = useIntl();
|
||||
const [modal, setModal] = useState(null);
|
||||
const router = useRouter();
|
||||
|
||||
const handleReset = async () => {
|
||||
setModal(null);
|
||||
onSave();
|
||||
onSave('reset');
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
onSave();
|
||||
await router.push('/websites');
|
||||
onSave('delete');
|
||||
};
|
||||
|
||||
const handleClose = () => setModal(null);
|
||||
|
||||
return (
|
||||
<Form>
|
||||
<FormRow label={formatMessage(labels.resetWebsite)}>
|
||||
<p>{formatMessage(messages.resetWebsiteWarning)}</p>
|
||||
<Button onClick={() => setModal('reset')}>{formatMessage(labels.reset)}</Button>
|
||||
<ModalTrigger>
|
||||
<Button>{formatMessage(labels.reset)}</Button>
|
||||
<Modal title={formatMessage(labels.resetWebsite)}>
|
||||
{close => (
|
||||
<WebsiteResetForm websiteId={websiteId} onSave={handleReset} onClose={close} />
|
||||
)}
|
||||
</Modal>
|
||||
</ModalTrigger>
|
||||
</FormRow>
|
||||
<FormRow label={formatMessage(labels.deleteWebsite)}>
|
||||
<p>{formatMessage(messages.deleteWebsiteWarning)}</p>
|
||||
<Button onClick={() => setModal('delete')}>Delete</Button>
|
||||
<ModalTrigger>
|
||||
<Button>Delete</Button>
|
||||
<Modal title={formatMessage(labels.deleteWebsite)}>
|
||||
{close => (
|
||||
<WebsiteDeleteForm websiteId={websiteId} onSave={handleDelete} onClose={close} />
|
||||
)}
|
||||
</Modal>
|
||||
</ModalTrigger>
|
||||
</FormRow>
|
||||
{modal === 'reset' && (
|
||||
<Modal title={formatMessage(labels.resetWebsite)} onClose={handleClose}>
|
||||
{close => <WebsiteResetForm websiteId={websiteId} onSave={handleReset} onClose={close} />}
|
||||
</Modal>
|
||||
)}
|
||||
{modal === 'delete' && (
|
||||
<Modal title={formatMessage(labels.deleteWebsite)} onClose={handleClose}>
|
||||
{close => (
|
||||
<WebsiteDeleteForm websiteId={websiteId} onSave={handleDelete} onClose={close} />
|
||||
)}
|
||||
</Modal>
|
||||
)}
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue