mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 03:55:37 +01:00
Converted mutation queries.
This commit is contained in:
parent
3f167e05ba
commit
0f9669f886
34 changed files with 259 additions and 350 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useApi, useMessages, useModified } from '@/components/hooks';
|
||||
import { useDeleteQuery, useMessages } from '@/components/hooks';
|
||||
import { TypeConfirmationForm } from '@/components/common/TypeConfirmationForm';
|
||||
|
||||
const CONFIRM_VALUE = 'DELETE';
|
||||
|
|
@ -13,11 +13,7 @@ export function WebsiteDeleteForm({
|
|||
onClose?: () => void;
|
||||
}) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { del, useMutation } = useApi();
|
||||
const { mutate, isPending, error } = useMutation({
|
||||
mutationFn: () => del(`/websites/${websiteId}`),
|
||||
});
|
||||
const { touch } = useModified();
|
||||
const { mutate, isPending, error, touch } = useDeleteQuery(`/websites/${websiteId}`);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
mutate(null, {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,11 @@
|
|||
import {
|
||||
FormSubmitButton,
|
||||
Form,
|
||||
FormField,
|
||||
FormButtons,
|
||||
TextField,
|
||||
useToast,
|
||||
} from '@umami/react-zen';
|
||||
import { useApi, useMessages, useModified, useWebsite } from '@/components/hooks';
|
||||
import { FormSubmitButton, Form, FormField, FormButtons, TextField } from '@umami/react-zen';
|
||||
import { useMessages, useUpdateQuery, useWebsite } from '@/components/hooks';
|
||||
import { DOMAIN_REGEX } from '@/lib/constants';
|
||||
|
||||
export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSave?: () => void }) {
|
||||
const website = useWebsite();
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { post, useMutation } = useApi();
|
||||
const { toast } = useToast();
|
||||
const { touch } = useModified();
|
||||
|
||||
const { mutate, error } = useMutation({
|
||||
mutationFn: (data: any) => post(`/websites/${websiteId}`, data),
|
||||
});
|
||||
const { mutate, error, touch, toast } = useUpdateQuery(`/websites/${websiteId}`);
|
||||
|
||||
const handleSubmit = async (data: any) => {
|
||||
mutate(data, {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useApi, useMessages } from '@/components/hooks';
|
||||
import { useMessages, useUpdateQuery } from '@/components/hooks';
|
||||
import { TypeConfirmationForm } from '@/components/common/TypeConfirmationForm';
|
||||
|
||||
const CONFIRM_VALUE = 'RESET';
|
||||
|
|
@ -13,10 +13,7 @@ export function WebsiteResetForm({
|
|||
onClose?: () => void;
|
||||
}) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { post, useMutation } = useApi();
|
||||
const { mutate, isPending, error } = useMutation({
|
||||
mutationFn: (data: any) => post(`/websites/${websiteId}/reset`, data),
|
||||
});
|
||||
const { mutate, isPending, error } = useUpdateQuery(`/websites/${websiteId}/reset`);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
mutate(null, {
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@ import {
|
|||
FormSubmitButton,
|
||||
Column,
|
||||
Label,
|
||||
useToast,
|
||||
Row,
|
||||
} from '@umami/react-zen';
|
||||
import { useState } from 'react';
|
||||
import { getRandomChars } from '@/lib/crypto';
|
||||
import { useApi, useMessages, useModified } from '@/components/hooks';
|
||||
import { useMessages, useUpdateQuery } from '@/components/hooks';
|
||||
|
||||
const generateId = () => getRandomChars(16);
|
||||
|
||||
|
|
@ -26,12 +25,7 @@ export interface WebsiteShareFormProps {
|
|||
export function WebsiteShareForm({ websiteId, shareId, onSave, onClose }: WebsiteShareFormProps) {
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const [id, setId] = useState(shareId);
|
||||
const { post, useMutation } = useApi();
|
||||
const { mutate, error, isPending } = useMutation({
|
||||
mutationFn: (data: any) => post(`/websites/${websiteId}`, data),
|
||||
});
|
||||
const { touch } = useModified();
|
||||
const { toast } = useToast();
|
||||
const { mutate, error, isPending, touch, toast } = useUpdateQuery(`/websites/${websiteId}`);
|
||||
|
||||
const url = `${window?.location.origin || ''}${process.env.basePath || ''}/share/${id}`;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue