mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 01:55:36 +01:00
Updated query hooks for teams and websites.
This commit is contained in:
parent
9448aa3ab5
commit
2fa50892d8
61 changed files with 508 additions and 539 deletions
|
|
@ -1,29 +1,28 @@
|
|||
import { Button, Form, FormButtons, SubmitButton } from 'react-basics';
|
||||
import { useApi } from 'components/hooks';
|
||||
import { useMessages } from 'components/hooks';
|
||||
import { setValue } from 'store/cache';
|
||||
import { useApi, useMessages } from 'components/hooks';
|
||||
import { touch } from 'store/cache';
|
||||
import TypeConfirmationForm from 'components/common/TypeConfirmationForm';
|
||||
|
||||
const CONFIRM_VALUE = 'DELETE';
|
||||
|
||||
export function TeamDeleteForm({
|
||||
teamId,
|
||||
teamName,
|
||||
onSave,
|
||||
onClose,
|
||||
}: {
|
||||
teamId: string;
|
||||
teamName: string;
|
||||
onSave: () => void;
|
||||
onClose: () => void;
|
||||
onSave?: () => void;
|
||||
onClose?: () => void;
|
||||
}) {
|
||||
const { formatMessage, labels, messages, FormattedMessage } = useMessages();
|
||||
const { labels, formatMessage } = useMessages();
|
||||
const { del, useMutation } = useApi();
|
||||
const { mutate, error, isPending } = useMutation({
|
||||
mutationFn: (data: any) => del(`/teams/${teamId}`, data),
|
||||
});
|
||||
|
||||
const handleSubmit = async data => {
|
||||
mutate(data, {
|
||||
const handleConfirm = async () => {
|
||||
mutate(null, {
|
||||
onSuccess: async () => {
|
||||
setValue('teams', Date.now());
|
||||
touch('teams');
|
||||
onSave?.();
|
||||
onClose?.();
|
||||
},
|
||||
|
|
@ -31,17 +30,15 @@ export function TeamDeleteForm({
|
|||
};
|
||||
|
||||
return (
|
||||
<Form onSubmit={handleSubmit} error={error}>
|
||||
<p>
|
||||
<FormattedMessage {...messages.confirmDelete} values={{ target: <b>{teamName}</b> }} />
|
||||
</p>
|
||||
<FormButtons flex>
|
||||
<SubmitButton variant="danger" disabled={isPending}>
|
||||
{formatMessage(labels.delete)}
|
||||
</SubmitButton>
|
||||
<Button onClick={onClose}>{formatMessage(labels.cancel)}</Button>
|
||||
</FormButtons>
|
||||
</Form>
|
||||
<TypeConfirmationForm
|
||||
confirmationValue={CONFIRM_VALUE}
|
||||
onConfirm={handleConfirm}
|
||||
onClose={onClose}
|
||||
isLoading={isPending}
|
||||
error={error}
|
||||
buttonLabel={formatMessage(labels.delete)}
|
||||
buttonVariant="danger"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue