mirror of
https://github.com/umami-software/umami.git
synced 2026-02-16 18:45:36 +01:00
Refactored forms and pages.
This commit is contained in:
parent
1325abe31d
commit
6253d55790
57 changed files with 209 additions and 208 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
Button,
|
||||
SubmitButton,
|
||||
} from 'react-basics';
|
||||
import { setValue } from 'store/cache';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import useMessages from 'components/hooks/useMessages';
|
||||
|
||||
|
|
@ -20,8 +21,9 @@ export function TeamAddForm({ onSave, onClose }) {
|
|||
const handleSubmit = async data => {
|
||||
mutate(data, {
|
||||
onSuccess: async () => {
|
||||
onSave();
|
||||
onClose();
|
||||
setValue('teams', Date.now());
|
||||
onSave?.();
|
||||
onClose?.();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { Button, Form, FormButtons, SubmitButton } from 'react-basics';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import useMessages from 'components/hooks/useMessages';
|
||||
import { setValue } from 'store/cache';
|
||||
|
||||
export function TeamDeleteForm({ teamId, teamName, onSave, onClose }) {
|
||||
const { formatMessage, labels, messages, FormattedMessage } = useMessages();
|
||||
|
|
@ -10,8 +11,9 @@ export function TeamDeleteForm({ teamId, teamName, onSave, onClose }) {
|
|||
const handleSubmit = async data => {
|
||||
mutate(data, {
|
||||
onSuccess: async () => {
|
||||
onSave();
|
||||
onClose();
|
||||
setValue('teams', Date.now());
|
||||
onSave?.();
|
||||
onClose?.();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@ export function TeamsTable({ data = [] }) {
|
|||
|
||||
return (
|
||||
<>
|
||||
{showDelete && <TeamDeleteButton teamId={id} teamName={name} />}
|
||||
{!showDelete && <TeamLeaveButton teamId={id} teamName={name} />}
|
||||
<Link href={`/settings/teams/${id}`}>
|
||||
<Button>
|
||||
<Icon>
|
||||
<Icons.Edit />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.view)}</Text>
|
||||
<Text>{formatMessage(labels.edit)}</Text>
|
||||
</Button>
|
||||
</Link>
|
||||
{showDelete && <TeamDeleteButton teamId={id} teamName={name} />}
|
||||
{!showDelete && <TeamLeaveButton teamId={id} teamName={name} />}
|
||||
</>
|
||||
);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Button, Form, FormButtons, GridColumn, Loading, SubmitButton, Toggle }
|
|||
import useMessages from 'components/hooks/useMessages';
|
||||
import WebsitesDataTable from '../../websites/WebsitesDataTable';
|
||||
|
||||
export function TeamAddWebsiteForm({ teamId, onSave, onClose }) {
|
||||
export function TeamWebsiteAddForm({ teamId, onSave, onClose }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { get, post, useQuery, useMutation } = useApi();
|
||||
const { mutate, error } = useMutation(data => post(`/teams/${teamId}/websites`, data));
|
||||
|
|
@ -57,4 +57,4 @@ export function TeamAddWebsiteForm({ teamId, onSave, onClose }) {
|
|||
);
|
||||
}
|
||||
|
||||
export default TeamAddWebsiteForm;
|
||||
export default TeamWebsiteAddForm;
|
||||
|
|
@ -7,15 +7,12 @@ export function TeamWebsiteRemoveButton({ teamId, websiteId, onSave }) {
|
|||
const { del, useMutation } = useApi();
|
||||
const { mutate, isLoading } = useMutation(() => del(`/teams/${teamId}/websites/${websiteId}`));
|
||||
|
||||
const handleRemoveTeamMember = () => {
|
||||
mutate(
|
||||
{},
|
||||
{
|
||||
onSuccess: () => {
|
||||
onSave();
|
||||
},
|
||||
const handleRemoveTeamMember = async () => {
|
||||
await mutate(null, {
|
||||
onSuccess: () => {
|
||||
onSave();
|
||||
},
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { ActionForm, Button, Icon, Icons, Modal, ModalTrigger, Text } from 'react-basics';
|
||||
import TeamWebsitesTable from './TeamWebsitesTable';
|
||||
import TeamAddWebsiteForm from './TeamAddWebsiteForm';
|
||||
import TeamWebsiteAddForm from './TeamWebsiteAddForm';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import useMessages from 'components/hooks/useMessages';
|
||||
import useUser from 'components/hooks/useUser';
|
||||
|
|
@ -36,7 +36,7 @@ export function TeamWebsites({ teamId }) {
|
|||
<Text>{formatMessage(labels.addWebsite)}</Text>
|
||||
</Button>
|
||||
<Modal title={formatMessage(labels.addWebsite)}>
|
||||
{close => <TeamAddWebsiteForm teamId={teamId} onSave={handleChange} onClose={close} />}
|
||||
{close => <TeamWebsiteAddForm teamId={teamId} onSave={handleChange} onClose={close} />}
|
||||
</Modal>
|
||||
</ModalTrigger>
|
||||
</ActionForm>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue