mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12: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,5 +1,4 @@
|
|||
import { useState } from 'react';
|
||||
import { Button, Icon, Text, Modal, useToast, Icons } from 'react-basics';
|
||||
import { Button, Icon, Text, Modal, ModalTrigger, useToast, Icons } from 'react-basics';
|
||||
import { useIntl } from 'react-intl';
|
||||
import Page from 'components/layout/Page';
|
||||
import PageHeader from 'components/layout/PageHeader';
|
||||
|
|
@ -10,10 +9,7 @@ import useApi from 'hooks/useApi';
|
|||
import useUser from 'hooks/useUser';
|
||||
import { labels, messages } from 'components/messages';
|
||||
|
||||
const { Plus } = Icons;
|
||||
|
||||
export default function WebsitesList() {
|
||||
const [edit, setEdit] = useState(false);
|
||||
const { user } = useUser();
|
||||
const { get, useQuery } = useApi();
|
||||
const { data, isLoading, error, refetch } = useQuery(
|
||||
|
|
@ -27,21 +23,21 @@ export default function WebsitesList() {
|
|||
|
||||
const handleSave = async () => {
|
||||
await refetch();
|
||||
setEdit(false);
|
||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||
};
|
||||
|
||||
const handleAdd = () => setEdit(true);
|
||||
|
||||
const handleClose = () => setEdit(false);
|
||||
|
||||
const addButton = (
|
||||
<Button variant="primary" onClick={handleAdd}>
|
||||
<Icon>
|
||||
<Plus />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.addWebsite)}</Text>
|
||||
</Button>
|
||||
<ModalTrigger>
|
||||
<Button variant="primary">
|
||||
<Icon>
|
||||
<Icons.Plus />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.addWebsite)}</Text>
|
||||
</Button>
|
||||
<Modal title={formatMessage(labels.addWebsite)}>
|
||||
{close => <WebsiteAddForm onSave={handleSave} onClose={close} />}
|
||||
</Modal>
|
||||
</ModalTrigger>
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -54,11 +50,6 @@ export default function WebsitesList() {
|
|||
{addButton}
|
||||
</EmptyPlaceholder>
|
||||
)}
|
||||
{edit && (
|
||||
<Modal title={formatMessage(labels.addWebsite)} onClose={handleClose}>
|
||||
{close => <WebsiteAddForm onSave={handleSave} onClose={close} />}
|
||||
</Modal>
|
||||
)}
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue